SCI Seg3D Mailing List

Text archives Help


[Seg3D] Fix for 2.1.4 segfault in Ubuntu Precise


Chronological Thread 
  • From: Robert Blake <rob.c.blake.3@gmail.com>
  • To: seg3d@sci.utah.edu
  • Subject: [Seg3D] Fix for 2.1.4 segfault in Ubuntu Precise
  • Date: Wed, 05 Feb 2014 01:08:56 -0500

Hi everyone,

I'm a big fan of Seg3D, but over the last year+ I've noticed some
instability in the Linux version on Ubuntu precise, 12.04.  Seg3D tends
to crash intermittently when opening up any file dialog.

Someone has already filed a bug report for this bug-- this is the same
behavior that I am seeing:
https://gforge.sci.utah.edu/gf/project/seg3d2/tracker/?action=TrackerItemEdit&tracker_id=710&tracker_item_id=772


jeoren checked in the following fix for this:
https://gforge.sci.utah.edu/svn/seg3d2/trunk@1708

However, this fix doesn't actually solve the problem.

As far as I can tell, the the problem occurs when Seg3D tries to load a
native file dialog on Ubuntu.  This causes a gtk-2 file dialog to
appear, which in turn uses libfreetype to render the dialog.  Ubuntu's
gtk-2 libraries expect to use the updated Ubuntu libfreetype libraries,
but instead they access Seg3D's internal statically linked libfreetype
library instead.  This causes intermittent invalid memory accesses.

I've attached a patch for 2.1.4 that DOES seem to solve the problem once
and for Linux, although it is an ugly kludge.  I replaced all of the
native file dialogs with Qt file dialogs.  I've been using this version
heavily for 1 week and it hasn't segfaulted once.

Sending this patch here in case someone else has the same problem.
Rob

diff --git a/src/Interface/Application/LayerIOFunctions.cc b/src/Interface/Application/LayerIOFunctions.cc
index 752a0fe..5b806de 100755
--- a/src/Interface/Application/LayerIOFunctions.cc
+++ b/src/Interface/Application/LayerIOFunctions.cc
@@ -102,12 +102,13 @@ bool LayerIOFunctions::ImportFiles( QMainWindow* main_window, std::string file_t
 #if defined(__APPLE__) || defined(_WIN32)
         // Use native dialog
 		file_list = QFileDialog::getOpenFileNames( main_window, 
-			"Import Layer(s)... ", current_file_folder.string().c_str(), filters, &qs_filtername );
+			"Import Layer(s)... ", current_file_folder.string().c_str(), filters, &qs_filtername, QFileDialog::DontUseNativeDialog );
 #else
         // It seems Ubuntus Qt4 version is broken and its dialog tends to crash
         // Hence use the other way of defining a dialog
         QFileDialog* diag = new QFileDialog( main_window, "Import Layer(s)...", 
             current_file_folder.string().c_str(), filters );
+        diag->setOption(QFileDialog::DontUseNativeDialog);
         diag->setFileMode(QFileDialog::ExistingFiles);
         diag->setNameFilter( qs_filtername );
         diag->exec();
@@ -231,12 +232,13 @@ void LayerIOFunctions::ImportSeries( QMainWindow* main_window )
 #if defined(__APPLE__) || defined(_WIN32)
         // Use native dialog
 		file_list = QFileDialog::getOpenFileNames( main_window, 
-			"Select a file from the series... ", current_file_folder.string().c_str(), filters, &filtername );
+			"Select a file from the series... ", current_file_folder.string().c_str(), filters, &filtername, QFileDialog::DontUseNativeDialog );
 #else
         // It seems Ubuntus Qt4 version is broken and its dialog tends to crash
         // Hence use the other way of defining a dialog
         QFileDialog* diag = new QFileDialog( main_window, "Select a file from the series...", 
             current_file_folder.string().c_str(), filters );
+        diag->setOption(QFileDialog::DontUseNativeDialog);
         diag->setFileMode(QFileDialog::ExistingFiles);
         diag->setNameFilter( filtername );
         diag->exec();
@@ -334,7 +336,8 @@ void LayerIOFunctions::ExportLayer( QMainWindow* main_window )
 
 	QString filename = QFileDialog::getSaveFileName( main_window, "Export Data Layer As... ",
 		QString::fromStdString( file_path.string() ),
-		"NRRD files (*.nrrd);;DICOM files (*.dcm);;TIFF files (*.tiff);;PNG files (*.png);;MRC files (*.mrc);;Matlab files (*.mat)" );
+		"NRRD files (*.nrrd);;DICOM files (*.dcm);;TIFF files (*.tiff);;PNG files (*.png);;MRC files (*.mrc);;Matlab files (*.mat)",
+		0, QFileDialog::DontUseNativeDialog );
 	
 	if( filename == "" ) return;
 	
diff --git a/src/Interface/Application/LayerWidget.cc b/src/Interface/Application/LayerWidget.cc
index c129922..292a627 100644
--- a/src/Interface/Application/LayerWidget.cc
+++ b/src/Interface/Application/LayerWidget.cc
@@ -376,7 +376,7 @@ void LayerWidgetPrivate::export_layer( const std::string& type_extension )
 {
 	boost::filesystem::path current_folder = ProjectManager::Instance()->get_current_file_folder();
 	QString export_path = QFileDialog::getExistingDirectory( this->parent_, tr( "Choose Directory for Export..." ),
-		current_folder.string().c_str(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks );
+		current_folder.string().c_str(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog );
 
 	if( export_path == "" ) return;
 
diff --git a/src/Interface/Application/Menu.cc b/src/Interface/Application/Menu.cc
index 2e16638..985d930 100644
--- a/src/Interface/Application/Menu.cc
+++ b/src/Interface/Application/Menu.cc
@@ -663,7 +663,10 @@ void Menu::open_project()
 		QFileDialog::getOpenFileName ( this->main_window_, 
 		QString::fromStdString( project_type ), 
 		QString::fromStdString( current_projects_path.string() ), 
-		QString::fromStdString( project_file_type ) ) ).toStdString() ); 
+		QString::fromStdString( project_file_type ),
+		0,
+		QFileDialog::DontUseNativeDialog
+		) ).toStdString() ); 
 
 #else
         // It seems Ubuntus Qt4 version is broken and its dialog tends to crash
@@ -672,6 +675,7 @@ void Menu::open_project()
             QString::fromStdString( project_type ), 
             QString::fromStdString( current_projects_path.string() ), 
             QString::fromStdString( project_file_type ) );
+        diag->setOption(QFileDialog::DontUseNativeDialog);
         diag->setFileMode(QFileDialog::ExistingFile);
         diag->exec();
         
diff --git a/src/Interface/Application/PreferencesInterface.cc b/src/Interface/Application/PreferencesInterface.cc
index 09c8e2c..6753a8f 100644
--- a/src/Interface/Application/PreferencesInterface.cc
+++ b/src/Interface/Application/PreferencesInterface.cc
@@ -105,7 +105,7 @@ PreferencesInterface::~PreferencesInterface()
 void PreferencesInterface::change_project_directory()
 {
 	QString path = QFileDialog::getExistingDirectory ( this, tr( "Directory" ), 
-		project_directory_.path() );
+		project_directory_.path(), QFileDialog::ShowDirsOnly | QFileDialog::DontUseNativeDialog );
     if ( path.isNull() == false )
     {
         project_directory_.setPath( path );
diff --git a/src/Interface/Application/ProjectExportWizard.cc b/src/Interface/Application/ProjectExportWizard.cc
index 30674a2..3129480 100644
--- a/src/Interface/Application/ProjectExportWizard.cc
+++ b/src/Interface/Application/ProjectExportWizard.cc
@@ -128,7 +128,8 @@ void ExportInfoPage::set_path()
 	
     QDir project_directory_ = QDir( QFileDialog::getExistingDirectory ( this, 
 		tr( "Choose Directory for Export..." ), this->project_path_lineedit_->text(), 
-		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ) );
+		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks |
+		QFileDialog::DontUseNativeDialog ) );
 	
     if ( project_directory_.exists() )
     {
diff --git a/src/Interface/Application/ProjectWizard.cc b/src/Interface/Application/ProjectWizard.cc
index 14cc4b4..ddc5016 100644
--- a/src/Interface/Application/ProjectWizard.cc
+++ b/src/Interface/Application/ProjectWizard.cc
@@ -165,7 +165,8 @@ void ProjectInfoPage::set_path()
 	
     QDir project_directory_ = QDir( QFileDialog::getExistingDirectory ( 
 		this, "Choose Directory...", this->project_path_lineedit_->text(), 
-		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ) );
+		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks |
+		QFileDialog::DontUseNativeDialog ) );
 	
     if ( project_directory_.exists() )
     {
diff --git a/src/Interface/Application/SaveProjectAsWizard.cc b/src/Interface/Application/SaveProjectAsWizard.cc
index b646b66..5eb226f 100644
--- a/src/Interface/Application/SaveProjectAsWizard.cc
+++ b/src/Interface/Application/SaveProjectAsWizard.cc
@@ -177,7 +177,8 @@ void SaveAsInfoPage::set_path()
 
     QDir project_directory_ = QDir( QFileDialog::getExistingDirectory ( this, 
 		tr( "Choose Save Directory..." ), this->project_path_lineedit_->text(), 
-		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks  ) );
+		QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks |
+		QFileDialog::DontUseNativeDialog ) );
 	
 	if( project_directory_.exists() )
     {
diff --git a/src/Interface/Application/SegmentationExportWizard.cc b/src/Interface/Application/SegmentationExportWizard.cc
index 737420c..7ee503e 100644
--- a/src/Interface/Application/SegmentationExportWizard.cc
+++ b/src/Interface/Application/SegmentationExportWizard.cc
@@ -337,13 +337,15 @@ bool SegmentationSelectionPage::validatePage()
              " File (*"  + file_type + ")";
     
 		filename = QFileDialog::getSaveFileName( this, "Export Segmentation As... ",
-			current_folder.string().c_str(), QString::fromStdString( file_selector ) );
+			current_folder.string().c_str(), QString::fromStdString( file_selector ),
+			0, QFileDialog::DontUseNativeDialog
+			);
 	}
 	else
 	{
 		filename = QFileDialog::getExistingDirectory( this, tr( "Choose Directory for Export..." ),
 			current_folder.string().c_str(), QFileDialog::ShowDirsOnly | 
-                QFileDialog::DontResolveSymlinks );
+                QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog );
 			
 		if( !QFileInfo( filename ).exists() )
 		{
diff --git a/src/Interface/Application/SplashScreen.cc b/src/Interface/Application/SplashScreen.cc
index 211a3d5..0aaa3b4 100644
--- a/src/Interface/Application/SplashScreen.cc
+++ b/src/Interface/Application/SplashScreen.cc
@@ -180,9 +180,12 @@ void SplashScreen::open_existing()
 
 	boost::filesystem::path full_path =  boost::filesystem::path( ( 
 		QFileDialog::getOpenFileName ( 0, 
-		QString::fromStdString( project_type ), 
-		QString::fromStdString( current_projects_path.string() ), 
-		QString::fromStdString( project_file_type ) ) ).toStdString() ); 
+			QString::fromStdString( project_type ),
+			QString::fromStdString( current_projects_path.string() ),
+			QString::fromStdString( project_file_type ),
+			0,
+			QFileDialog::DontUseNativeDialog
+                ) ).toStdString() );
 
 	bool is_path_extension = false;
 	for ( size_t j = 0; j < project_path_extensions.size(); j++ )



Archive powered by MHonArc 2.6.18.

Top of page