mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	Postpone error message display if not in GUI thread
Calls to report_error() crashed if not called from GUI thread. Fix this by postponing error message display if not in GUI thread. Code that creates a thread which possibly calls report_error() is responsible for calling MainWindow::showErrors() to flush the accumulated messages. Note that there is a race condition in report_error() and get_error_string(). Nevertheless, hitting it should be rather unlikely (two threads producing error messages at the same time) and hopefully it can be fixed rather easily. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									945a0a8748
								
							
						
					
					
						commit
						3acc28cebf
					
				
					 3 changed files with 21 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -88,12 +88,22 @@ MainWindow *MainWindow::m_Instance = NULL;
 | 
			
		|||
 | 
			
		||||
extern "C" void showErrorFromC()
 | 
			
		||||
{
 | 
			
		||||
	// Show errors only if we are running in the GUI thread.
 | 
			
		||||
	// If we're not in the GUI thread, let errors accumulate.
 | 
			
		||||
	if (QThread::currentThread() != QCoreApplication::instance()->thread())
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	MainWindow *mainwindow = MainWindow::instance();
 | 
			
		||||
	if (mainwindow) {
 | 
			
		||||
		mainwindow->getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
 | 
			
		||||
	}
 | 
			
		||||
	if (mainwindow)
 | 
			
		||||
		mainwindow->showErrors();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MainWindow::showErrors()
 | 
			
		||||
{
 | 
			
		||||
	const char *error = get_error_string();
 | 
			
		||||
	if (error && error[0])
 | 
			
		||||
		getNotificationWidget()->showNotification(error, KMessageWidget::Error);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
MainWindow::MainWindow() : QMainWindow(),
 | 
			
		||||
	actionNextDive(0),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue