If the application "Interface Crashed" dialog is shown at startup, it can cause Application to receive events before it has been fully constructed. In this case the QMainWindow _window pointer is uninitialized, causing Menu::getInstance() to de-reference an invalid pointer. The fix for this is three fold. 1. Construct the QMainWindow before calling setupEssentials (which in turn spawns the "Interface Crashed" dialog). 2. Change Menu::getInstance() from a static_cast to a dynamic_cast. This will cause it to return a nullptr if [QMainWindow::menuBar()](http://doc.qt.io/qt-4.8/qmainwindow.html#menuBar) returns an instance of QMenuBar and not a ui::Menu instance. 3. In Application::event return false if Menu::getInstance() returns a nullptr. This should prevent any code that relies on having a valid ui::Menu instance from running.
Showing the changes to interface/src/Application.cpp (1 of 3 files). Show all
Unified · Split
| @@ -452,8 +452,8 @@ Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context); · 451 unmodified lines | |||
| 452 | 452 | ||
| 453 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : | 453 | Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) : |
| 454 | QApplication(argc, argv), | 454 | QApplication(argc, argv), |
| 455 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), | ||
| 456 | _window(new MainWindow(desktop())), | 455 | _window(new MainWindow(desktop())), |
| 456 | _dependencyManagerIsSetup(setupEssentials(argc, argv)), | ||
| 457 | _undoStackScriptingInterface(&_undoStack), | 457 | _undoStackScriptingInterface(&_undoStack), |
| 458 | _frameCount(0), | 458 | _frameCount(0), |
| 459 | _fps(60.0f), | 459 | _fps(60.0f), |
| @@ -1744,6 +1744,11 @@ bool Application::importSVOFromURL(const QString& urlString) { · 1284 unmodified lines | |||
| 1744 | } | 1744 | } |
| 1745 | 1745 | ||
| 1746 | bool Application::event(QEvent* event) { | 1746 | bool Application::event(QEvent* event) { |
| 1747 | |||
| 1748 | if (!Menu::getInstance()) { | ||
| 1749 | return false; | ||
| 1750 | } | ||
| 1751 | |||
| 1747 | if ((int)event->type() == (int)Lambda) { | 1752 | if ((int)event->type() == (int)Lambda) { |
| 1748 | ((LambdaEvent*)event)->call(); | 1753 | ((LambdaEvent*)event)->call(); |
| 1749 | return true; | 1754 | return true; |