OscMessage Inside An std::vector


#1

I am attempting to create a ‘buffer’ of OscMessages by creating a vector with value type OSCMessage. When trying to send these OSC messages, I get bad access errors/ throw out of range errors from the vector when using operator or .at. There is an address and argument in the OSC message, what is the cause of this error?
edit: added photos
Screen Shot

Screen Shot 3


#2

Are you doing things thread-safely?


#3

Which parts of the OSC classes would involve doing things thread safely? I didn’t think separate threads were used in the OSCMessage class?


#4

OK, looks like you just have an error in your for loop that iterates the vector. The condition should not be <= but < instead. (The last valid element index in the vector is size()-1, not size().)


#5

I can’t believe after 2 hours of bug searching that was the problem… Thanks for the quick fix!


#6

Also, since it’s a vector, you could use an Iterator to access it, in which case you wouldn’t have had this error. :slight_smile:


#7

Or C++11 range-based for loop… :wink: