[rkward-cvs] SF.net SVN: rkward:[2692] trunk/rkward/rkward/plugin/rkstandardcomponent. cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Oct 6 15:11:00 UTC 2009


Revision: 2692
          http://rkward.svn.sourceforge.net/rkward/?rev=2692&view=rev
Author:   tfry
Date:     2009-10-06 15:11:00 +0000 (Tue, 06 Oct 2009)

Log Message:
-----------
Fix yet more crashes on plugin tests

Modified Paths:
--------------
    trunk/rkward/rkward/plugin/rkstandardcomponent.cpp

Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2009-10-06 13:17:42 UTC (rev 2691)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp	2009-10-06 15:11:00 UTC (rev 2692)
@@ -25,6 +25,7 @@
 #include <QVBoxLayout>
 #include <QGroupBox>
 #include <QTime>
+#include <QObjectCleanupHandler>
 
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -328,6 +329,10 @@
 bool RKStandardComponent::submit (int max_wait, RCommandChain *in_chain) {
 	RK_TRACE (PLUGIN);
 
+	// the call to processEvents(), below, is quite dangerous, as the component self-destructs on errors. This helps us prevent crashes.
+	QObjectCleanupHandler chandler;
+	chandler.add (this);
+
 	RCommandChain *old_chain = command_chain; 	// should always be 0, but let's store it cleanly
 	command_chain = in_chain;
 	bool result = false;
@@ -335,9 +340,9 @@
 	QTime t;
 	t.start ();
 	while ((handle_change_timer->isActive () || backend->isBusy ()) && (t.elapsed () < max_wait)) {
-		if (killed) return (false);
+		if (chandler.isEmpty () || killed) return (false);
 		QCoreApplication::processEvents (QEventLoop::ExcludeUserInputEvents, (max_wait / 2));
-		if (killed) return (false);
+		if (chandler.isEmpty () || killed) return (false);
 	}
 	if (!(handle_change_timer->isActive () || backend->isBusy ())) {
 		if (isSatisfied ()) {
@@ -345,7 +350,9 @@
 			result = true;
 		}
 	}
+	if (chandler.isEmpty () || killed) return (result);
 	command_chain = old_chain;
+	chandler.remove (this);
 	return result;
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list