Mind you I'm using the default DRI mesa, which is not thread safe. Is this an issue? What pointers can you give me to track down why (*i) is going into la-la-land after the splash screen is cleared?
I dont think that this is a reason, because we use single thread right now.
Try check if (*i) is NULL. If this is a reason (this is the most possible way) then we must understand where it set to NULL.
How Screen classes work.
First, when we create ScreenManager object constructor add SplashScreen to vector of Screens
ScreenSplash* screen = new ScreenSplash();
PushScreen(screen);
This vector is drawing correctly
Next thing happens after we press space. In the input method of SplashScreen we asq screen manager to delete SplashScreen and add new Screen.
SCREENMAN->PopTopScreen();
ScreenDisplayTest* screen = new ScreenDisplayTest();
SCREENMAN->PushScreen(screen);
I dont see any errors here. Pointer to screen just added to vector. It must be creared otherwise it crushed.
PopTopScreen add pointer of SplashScreen to mScreensToDelete vector - vector of screens that should be deleted at the next Update of screenmanager. It also remove pointer from usual screens vector. (Posible error - mScreens.pop_back() doesn't remove pointer)
if (mScreens.size() > 0)
{
mScreensToDelete.push_back(mScreens[mScreens.size() - 1]);
mScreens.pop_back();
}
At the Update we jusr delete all pointers and clear the vector of screens that should be deleted.
for (int i = 0; i < mScreensToDelete.size(); ++i)
{
delete mScreensToDelete
;
}
mScreensToDelete.clear();
Thats all. I see only one posible error here, but still don't know why this happened.
Also, could you put the increment operater after the variable if it's not critical to have? That just looks wierd.
I can't and there is reason. postfix increment and decrement orerators create temporary object that should be returned, but prefix operators not, so we all must use prefix operators if there is no reason. Look for example this
http://www.devx.com/tips/Tip/12634, this is the first article that I found in google.