We are building plugins for QtCreator and one of the changes in QtCreator's code is causing crashes for us.
Basically the problem lies in MainWindow::addContextObject function and in destruction order.
MainWindow::addContextObject does this:
This code allows removeContextObject function to access m_contextWidgets even after MainWindow destructor has finished and m_contextWidgets is destroyed.
Happens when MainWindow::addContextObject is called by a grand-grand-grand.... child widget, which gets destroyed by MainWidget base class (that destroys all children).
As you see m_contextWidgets is destroyed by that time.
It works for QtCreator code because you do manual deletion in MainWindow destructor and does not let the object to be automatically destroyed by base class. If you would, it would crash for you as well (widgets that have Context registered).
Another way to handle this is to delete the widgets before MainWindow manually and not let the widget tree to do the job. This is what you do with HelpWidget.
If you remove the manual deletion of dd->m_centralWidget and let the widget tree to do the removal, then it does crash for you as well. (note that you have to comment out the whole HelpWidget destructor as well as it gets some other crashes before you reach this).
But this seems incorrect that I just can't let the widget tree to do the deletion of all the widgets automatically.
Wasn't a problem before this was introduced:
Can you fix so that we don't have to hack around it in our code and let the widget tree naturally delete everything?