Hi, my code injects a mouse movement, and when this code runs from GUIManager::injectMouseMove():
if( (mActiveWidget->getGrabbed()) && (mActiveWidget->draggingEnabled()) )
it calls line 709 of QuickGUIWidget.cpp for
bool Widget::getGrabbed() const
but the widget pointer isn't valid, presumably because mActiveWidget has not been set by QuickGUI. Exception!
Are you absolutely sure its a bad pointer? The GUIManager sets the pointer in its constructor:
mActiveWidget = mWidgetContainingMouse = mActiveSheet = mDefaultSheet;
It also sets it in GUIManager::setActiveSheet:
// Update the active widget
mActiveWidget = mActiveSheet;
The active widget should never be NULL, even with a blank screen it would be the sheet. Maybe you are deleting something that was the active widget? Although I cover this case also. You'd have to give more information on how you ran into this problem, the active widget should never be an invalid pointer.
You're right, the widget pointer was valid and set before the widget was deleted. Roughly, my code does this with widgets:
QuickGUI::Window *inputWdw = guiSheet->createWindow();
QuickGUI::Widget *currentWidget = inputWdw->createTextBox(wgtName);
currentWidget->setPosition(currentLineWidth + 10,totalHeight);
So I assume the problem is that you're deleting the child widgets in removeAndDestroyAllChildWidgets() without checking whether each widget is the active widget for the GUI manager and resetting that pointer if it is? You know, it might be safer to call/create a function for deleting a widget which all widget deletions in QuickGUI have to use -- one which does the event-firing you do in removeAndDestroyAllChildWidgets(), but also runs checks like whether it's the active widget/widget with focus, whether it's referred/pointer to in any other places... delete *widget just seems too blunt :)
I'm not sure if removeAndDestroyAllChildWidgets does any checking if the active widget is going to be deleted, I will have to check it out. You're right there should be one function to handle it all, so there is less to maintain.