Commit f2e91f0e authored by cutealien's avatar cutealien

Fix self assignments for irrArray (which worked already in 1.6, not sure if it was fixed there

already or broken after 1.6).


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2950 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 09b4f299
...@@ -247,8 +247,10 @@ public: ...@@ -247,8 +247,10 @@ public:
//! Assignment operator //! Assignment operator
void operator=(const array<T, TAlloc>& other) const array<T, TAlloc>& operator=(const array<T, TAlloc>& other)
{ {
if (this == &other)
return *this;
strategy = other.strategy; strategy = other.strategy;
if (data) if (data)
...@@ -267,6 +269,8 @@ public: ...@@ -267,6 +269,8 @@ public:
for (u32 i=0; i<other.used; ++i) for (u32 i=0; i<other.used; ++i)
allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i]; allocator.construct(&data[i], other.data[i]); // data[i] = other.data[i];
return *this;
} }
......
...@@ -13,6 +13,14 @@ struct VarArray ...@@ -13,6 +13,14 @@ struct VarArray
core::array < int, core::irrAllocatorFast<int> > MyArray; core::array < int, core::irrAllocatorFast<int> > MyArray;
}; };
bool testSelfAssignment()
{
core::array<int> myArray;
myArray.push_back(1);
myArray = myArray;
return myArray.size() == 1;
}
// this will (did once) simply crash when wrong, so no return value // this will (did once) simply crash when wrong, so no return value
void crashTestFastAlloc() void crashTestFastAlloc()
{ {
...@@ -36,6 +44,7 @@ bool testArray(void) ...@@ -36,6 +44,7 @@ bool testArray(void)
logTestString("crashTestFastAlloc\n"); logTestString("crashTestFastAlloc\n");
crashTestFastAlloc(); crashTestFastAlloc();
allExpected &= testSelfAssignment();
if(allExpected) if(allExpected)
logTestString("\nAll tests passed\n"); logTestString("\nAll tests passed\n");
......
Test suite pass at GMT Mon Nov 30 14:42:09 2009 Test suite pass at GMT Mon Nov 30 15:06:06 2009
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment