[Slad] SLADinstaller Patch: keep certain gtk calls out of thread

Jan-Oliver Wagner jan at intevation.de
Wed Mar 1 11:37:15 UTC 2006


Hi,

the attached patch keeps the call of GTK message dialogs
out of the thread.
Though it worked before on GNU/Linux,
on Windows we have problems - the application simply freezes.

I am not sure whether this is a bug in GTK, in Windows or
something else.

However, the solution of the patch should work also for
GNU/Linux. I haven't tested it yet apart from that it compiles.
So, please test before creating a new release.

Best

	Jan
-- 
Jan-Oliver Wagner: www.intevation.de/~jan  | GISpatcher: www.gispatcher.de
Kolab Konsortium : www.kolab-konsortium.de | Thuban    : thuban.intevation.org
Intevation GmbH  : www.intevation.de       | Kolab     : www.kolab.org
FreeGIS          : www.freegis.org         | GAV       : www.grass-verein.de
-------------- next part --------------
Index: gtk.cpp
===================================================================
RCS file: /anoncvs/sladinstaller/gtk.cpp,v
retrieving revision 1.49
diff -u -3 -p -r1.49 gtk.cpp
--- gtk.cpp	15 Feb 2006 10:52:13 -0000	1.49
+++ gtk.cpp	1 Mar 2006 11:31:07 -0000
@@ -166,6 +166,9 @@ struct ThreadData
   std::string sshpassphrase;
   std::string twsitepassphrase;
   std::string twlocalpassphrase;
+
+  int ret;
+  std::string result_message;
 };
 
 static gpointer ThreadFunc(gpointer data)
@@ -358,22 +361,22 @@ static gpointer ThreadFunc(gpointer data
 
   sshclose(sshhandle);
 
+  std::string s = "";
   gdk_threads_enter ();
   if(ret)
     {
       PROGRESS_(_("Installation failed!"));
       PROGRESS_(1.0);
-      std::string s=_("Installation was not successfull.");
+      s+=_("Installation was not successfull.");
       s+=' ';
       if(err.size())
 	s+=err;
       else
 	s+=_("See log window for details.");
-      ERROR(s.c_str());
     }
   else
     {
-      std::string s=_("Installation completed. Please note the SLAD passphrase and tripwire passphrases.");
+      s+=_("Installation completed. Please note the SLAD passphrase and tripwire passphrases.");
       s+='\n';
       if(filename_sshkey.size())
 	{
@@ -385,13 +388,15 @@ static gpointer ThreadFunc(gpointer data
 	  s+=_("The Tripwire passphrases and the SLAD passphrase are saved in:"); s+='\n'; s+=filename_sladconf;
 	  filename_sladconf.erase();
 	}
-      SUCCESS(s.c_str());
     }
+
+  td->ret = ret;
+  td->result_message = s;
   gdk_flush();
   gdk_threads_leave ();
 
   installthreadrun=false;
-  return gpointer(ret);
+  return td;
 }
 
 static gboolean installthreadcheck(gpointer data)
@@ -399,12 +404,19 @@ static gboolean installthreadcheck(gpoin
   if(installthreadrun)
     return true;
 
-  g_thread_join(installthread);
+  gdk_threads_enter();
+  ThreadData *td = reinterpret_cast<ThreadData*>(g_thread_join(installthread));
   installthread=0;
 
+  if (td->ret)
+    ERROR(td->result_message.c_str());
+  else
+    SUCCESS(td->result_message.c_str());
+
   // enable install button
   gtk_widget_set_sensitive(installbutton, true);
 
+  gdk_threads_leave();
   return false;
 }
 


More information about the Slad mailing list