Skip to content

Commit 5717977

Browse files
committed
consider possibility that an event might destroy QApplication
1 parent 2c32a66 commit 5717977

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

src/OpenCOVER/plugins/general/WindowTypeQt/WindowTypeQt.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,10 @@ bool WindowTypeQtPlugin::windowCreate(int i)
456456

457457
// std::cerr << "window " << i << ": ctx=" << coVRConfig::instance()->windows[i].context << std::endl;
458458

459-
qApp->sendPostedEvents();
460-
qApp->processEvents();
459+
if(qApp)
460+
qApp->sendPostedEvents();
461+
if(qApp)
462+
qApp->processEvents();
461463

462464
return true;
463465
}
@@ -495,10 +497,9 @@ void WindowTypeQtPlugin::aboutCover() const
495497
void WindowTypeQtPlugin::windowCheckEvents(int num)
496498
{
497499
if (qApp)
498-
{
499500
qApp->sendPostedEvents();
501+
if (qApp)
500502
qApp->processEvents();
501-
}
502503
}
503504

504505
void WindowTypeQtPlugin::windowUpdateContents(int num)
@@ -534,15 +535,20 @@ void WindowTypeQtPlugin::windowDestroy(int num)
534535
}
535536
delete win.widget;
536537
delete win.window;
537-
qApp->sendPostedEvents();
538-
qApp->processEvents();
538+
if (qApp)
539+
qApp->sendPostedEvents();
540+
if (qApp)
541+
qApp->processEvents();
539542
m_windows.erase(it);
540543

541544
if (m_deleteQApp && m_windows.empty())
542545
{
543-
qApp->quit();
544-
qApp->sendPostedEvents();
545-
qApp->processEvents();
546+
if (qApp)
547+
qApp->quit();
548+
if (qApp)
549+
qApp->sendPostedEvents();
550+
if (qApp)
551+
qApp->processEvents();
546552
delete qApp;
547553
}
548554
}

0 commit comments

Comments
 (0)