04-08-2012 01:14 PM
I have been using a Vector as a vehicle for transporting data between tasks since it can carry different objects.
I discovered the following:
1. Update String array with values
2. Put the array into the Vector.
3. Change the array
Result: The array is changed "inside" the Vector simply by changing it outside of the Vector. This came as absolute surprise to me. Is this behavior "by design"?? Played havoc with my code.
Solved! Go to Solution.
04-08-2012 04:03 PM
To me it makes sense since a vector is a collection of pointers, you are not actually storing the data in the vector but pointers to the data. If you change the data the vector points to then you would expect the vector to reflect your changes. You need to new your array to break free of this.
04-08-2012 05:26 PM
I suspected something like that. What makes it a bit confusimng is when you passes it to a new thread the pointers are still valid. And I did not find any reference in the documentation to thhis.