More proper app termination.
This commit is contained in:
		
							parent
							
								
									bd6b417cd8
								
							
						
					
					
						commit
						aa705b0ef5
					
				@ -40,6 +40,7 @@ Manager::Manager (QObject *parent) :
 | 
				
			|||||||
  connect (this, SIGNAL (settingsEdited ()),
 | 
					  connect (this, SIGNAL (settingsEdited ()),
 | 
				
			||||||
           recognizer, SLOT (applySettings ()));
 | 
					           recognizer, SLOT (applySettings ()));
 | 
				
			||||||
  QThread *recognizerThread = new QThread (this);
 | 
					  QThread *recognizerThread = new QThread (this);
 | 
				
			||||||
 | 
					  threads_ << recognizerThread;
 | 
				
			||||||
  recognizer->moveToThread (recognizerThread);
 | 
					  recognizer->moveToThread (recognizerThread);
 | 
				
			||||||
  recognizerThread->start ();
 | 
					  recognizerThread->start ();
 | 
				
			||||||
  connect (qApp, SIGNAL (aboutToQuit ()), recognizerThread, SLOT (quit ()));
 | 
					  connect (qApp, SIGNAL (aboutToQuit ()), recognizerThread, SLOT (quit ()));
 | 
				
			||||||
@ -54,6 +55,7 @@ Manager::Manager (QObject *parent) :
 | 
				
			|||||||
  connect (this, SIGNAL (settingsEdited ()),
 | 
					  connect (this, SIGNAL (settingsEdited ()),
 | 
				
			||||||
           translator, SLOT (applySettings ()));
 | 
					           translator, SLOT (applySettings ()));
 | 
				
			||||||
  QThread *translatorThread = new QThread (this);
 | 
					  QThread *translatorThread = new QThread (this);
 | 
				
			||||||
 | 
					  threads_ << translatorThread;
 | 
				
			||||||
  translator->moveToThread (translatorThread);
 | 
					  translator->moveToThread (translatorThread);
 | 
				
			||||||
  translatorThread->start ();
 | 
					  translatorThread->start ();
 | 
				
			||||||
  connect (qApp, SIGNAL (aboutToQuit ()), translatorThread, SLOT (quit ()));
 | 
					  connect (qApp, SIGNAL (aboutToQuit ()), translatorThread, SLOT (quit ()));
 | 
				
			||||||
@ -127,6 +129,10 @@ void Manager::applySettings () {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Manager::~Manager () {
 | 
					Manager::~Manager () {
 | 
				
			||||||
 | 
					  foreach (QThread * thread, threads_) {
 | 
				
			||||||
 | 
					    thread->quit ();
 | 
				
			||||||
 | 
					    thread->wait (1000000);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Manager::capture () {
 | 
					void Manager::capture () {
 | 
				
			||||||
 | 
				
			|||||||
@ -56,6 +56,8 @@ class Manager : public QObject {
 | 
				
			|||||||
    QAction *clipboardAction_;
 | 
					    QAction *clipboardAction_;
 | 
				
			||||||
    ProcessingItem lastItem_;
 | 
					    ProcessingItem lastItem_;
 | 
				
			||||||
    bool useResultDialog_;
 | 
					    bool useResultDialog_;
 | 
				
			||||||
 | 
					    //! Used threads. For proper termination.
 | 
				
			||||||
 | 
					    QList<QThread *> threads_;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif // MANAGER_H
 | 
					#endif // MANAGER_H
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user