\r
int icvInitSystem(int *c, char** v)\r
{\r
- static int wasInitialized = 0;\r
-\r
- // check initialization status\r
- if( !wasInitialized)\r
+ //"For any GUI application using Qt, there is precisely one QApplication object"\r
+ if(!QApplication::instance())\r
{\r
new QApplication(*c,v);\r
\r
- wasInitialized = 1;\r
qDebug()<<"init done";\r
\r
#if defined( HAVE_QT_OPENGL )\r
\r
GuiReceiver::GuiReceiver() : _bTimeOut(false), nb_windows(0)\r
{\r
+ doesExternalQAppExist = (QApplication::instance() != 0);\r
icvInitSystem(¶meterSystemC, parameterSystemV);\r
\r
timer = new QTimer;\r
{\r
delete guiMainThread;//delete global_control_panel too\r
guiMainThread = NULL;\r
- qApp->quit();\r
+ if(!doesExternalQAppExist)\r
+ {\r
+ qApp->quit();\r
+ }\r
}\r
}\r
\r
\r
if (multiThreads)\r
{\r
+ // WARNING: this could even close windows from an external parent app\r
+ //#TODO check externalQAppExists and in case it does, close windows carefully,\r
+ // i.e. apply the className-check from below...\r
qApp->closeAllWindows();\r
}else{\r
\r