1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-24 13:45:47 +00:00

Fix missed logic bugs in reordering of RenderObjects within a layer.

Because of wrongly set firstFreeIdx some pointers were NULL, where they
shouldn't be, which caused hard to track down crashes.
This is an addition to af04d0c37698.
This commit is contained in:
fgenesis 2012-02-05 20:31:17 +01:00
parent 99375127e1
commit ac822ec91d

View file

@ -242,7 +242,8 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
r->setIdx(size);
for (int i = size+1; i < newSize; i++)
renderObjects[i] = 0;
firstFreeIdx = curIdx;
if (firstFreeIdx > curIdx)
firstFreeIdx = curIdx;
}
else
{
@ -261,13 +262,10 @@ void RenderObjectLayer::moveToFront(RenderObject *r)
}
renderObjects[lastUsed] = r;
r->setIdx(lastUsed);
firstFreeIdx = curIdx;
firstFreeIdx = 0;
// Known to have at least one NULL-element
while (renderObjects[firstFreeIdx])
{
firstFreeIdx++;
if(firstFreeIdx >= size)
firstFreeIdx = 0;
}
}
#endif // RLT_FIXED
#ifdef RLT_DYNAMIC