fix_highgui_qt_multiple_qapp_error.diff

Path fixing the described defect - Linus Atorf, 2011-02-26 01:50 am

Download (1.3 kB)

 
window_QT.cpp (working copy)
56 56
//that is also the number of pixel per grid
57 57

  
58 58
static CvWinProperties* global_control_panel = NULL;
59

  
60
static bool externalQAppExists = false; // whether there already exists an "outside" qApp 
61

  
59 62
//end static and global
60 63

  
61 64

  
......
438 441
	// check initialization status
439 442
	if( !wasInitialized)
440 443
	{
441
		new QApplication(*c,v);
444
		// check if another "parent" app has already
445
		// created an app object...
446
		if (!QApplication::instance()) {
447
			new QApplication(*c,v);
448
		} else {
449
			externalQAppExists = true;
450
		}
442 451

  
443 452
		wasInitialized = 1;
444 453
		qDebug()<<"init done";
......
705 714
	{
706 715
		delete guiMainThread;//delete global_control_panel too
707 716
		guiMainThread = NULL;
708
		qApp->quit();
717
		// only quit if we created the QApp ourselves...
718
		if (!externalQAppExists) {
719
			qApp->quit();
720
		}
709 721
	}
710 722
}
711 723

  
......
974 986

  
975 987
	if (multiThreads)
976 988
	{
989
		// WARNING: this could even close windows from an external parent app
990
		//#TODO check externalQAppExists and in case it does, close windows carefully,
991
		//      i.e. apply the className-check from below...
977 992
		qApp->closeAllWindows();
978 993
	}else{
979 994