[rkward-cvs] SF.net SVN: rkward:[2682] trunk/rkward/rkward/plugin
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Oct 5 09:06:55 UTC 2009
Revision: 2682
http://rkward.svn.sourceforge.net/rkward/?rev=2682&view=rev
Author: tfry
Date: 2009-10-05 09:06:48 +0000 (Mon, 05 Oct 2009)
Log Message:
-----------
Somewhat safer destruction of standard component on errors (don't crash when an error occurs during auto-submit)
Modified Paths:
--------------
trunk/rkward/rkward/plugin/rkcomponentmap.cpp
trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
trunk/rkward/rkward/plugin/rkstandardcomponent.h
Modified: trunk/rkward/rkward/plugin/rkcomponentmap.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2009-10-03 20:43:49 UTC (rev 2681)
+++ trunk/rkward/rkward/plugin/rkcomponentmap.cpp 2009-10-05 09:06:48 UTC (rev 2682)
@@ -276,7 +276,9 @@
bool submit_ok = component->submit (50000, in_chain);
#endif
if (!submit_ok) {
- if (submit_mode == AutoSubmitOrFail) component->close ();
+ if (submit_mode == AutoSubmitOrFail) {
+ component->kill ();
+ }
_message.append (i18n ("\nThe plugin could not be auto-submitted with these settings."));
if (message) *message = _message;
Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.cpp
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2009-10-03 20:43:49 UTC (rev 2681)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.cpp 2009-10-05 09:06:48 UTC (rev 2682)
@@ -68,6 +68,7 @@
gui = 0;
wizard = 0;
created = false;
+ killed = false;
addChild ("code", code = new RKComponentPropertyCode (this, true)); // do not change this name!
code->setInternal (true);
@@ -76,8 +77,7 @@
QDomElement doc_element = xml->openXMLFile (filename, DL_ERROR);
if (xml->highestError () >= DL_ERROR) {
KMessageBox::error (this, i18n ("There has been an error while trying to parse the description of this plugin ('%1'). Please refer to stdout for details.", filename), i18n ("Could not create plugin"));
- removeFromParent ();
- deleteLater ();
+ kill ();
return;
}
@@ -101,9 +101,7 @@
}
connect (backend, SIGNAL (idle ()), this, SLOT (backendIdle ()));
connect (backend, SIGNAL (requestValue (const QString&)), this, SLOT (getValue (const QString&)));
- connect (backend, SIGNAL (haveError ()), this, SLOT (hide ()));
- connect (backend, SIGNAL (haveError ()), this, SLOT (removeFromParent ()));
- connect (backend, SIGNAL (haveError ()), this, SLOT (deleteLater ()));
+ connect (backend, SIGNAL (haveError ()), this, SLOT (kill ()));
if (!backend->initialize (code, parent_component == 0)) return;
// check for existence of help file
@@ -119,7 +117,7 @@
if (!parent_component) { // top-level
if (!createTopLevel (doc_element)) {
RK_ASSERT (false);
- deleteLater ();
+ kill ();
return; // should never happen
}
} else if (!parent_widget) { // we have a parent component, but should still have a separate GUI
@@ -127,7 +125,7 @@
if (parentComponent ()->isWizardish ()) force_mode = 2;
if (!createTopLevel (doc_element, force_mode, true)) {
RK_ASSERT (false);
- deleteLater ();
+ kill ();
return; // should never happen
}
} else {
@@ -150,7 +148,7 @@
gui_element = xml->getChildElement (doc_element, "dialog", DL_WARNING);
if (gui_element.isNull ()) {
xml->displayError (&doc_element, "Cannot embed a wizard into a dialog, and no dialog definition available", DL_ERROR);
- deleteLater ();
+ kill ();
return;
}
}
@@ -165,6 +163,17 @@
backend->destroy (); // it will self-destruct, when it has closed the process.
}
+void RKStandardComponent::kill () {
+ RK_TRACE (PLUGIN);
+
+ if (killed) return;
+ killed = true;
+
+ hide ();
+ removeFromParent ();
+ deleteLater ();
+}
+
void RKStandardComponent::hide () {
RK_TRACE (PLUGIN);
@@ -326,7 +335,9 @@
QTime t;
t.start ();
while ((handle_change_timer->isActive () || backend->isBusy ()) && (t.elapsed () < max_wait)) {
+ if (killed) return (false);
QCoreApplication::processEvents (QEventLoop::ExcludeUserInputEvents, (max_wait / 2));
+ if (killed) return (false);
}
if (!(handle_change_timer->isActive () || backend->isBusy ())) {
if (isSatisfied ()) {
Modified: trunk/rkward/rkward/plugin/rkstandardcomponent.h
===================================================================
--- trunk/rkward/rkward/plugin/rkstandardcomponent.h 2009-10-03 20:43:49 UTC (rev 2681)
+++ trunk/rkward/rkward/plugin/rkstandardcomponent.h 2009-10-05 09:06:48 UTC (rev 2682)
@@ -93,9 +93,11 @@
/** for enslaved components */
void showGUI ();
void handleChange ();
+ void kill ();
private:
/** The property holding the generated code. Note that this member is tightly controlled by the ScriptBackend */
RKComponentPropertyCode *code;
+ bool killed;
QString filename;
bool have_help; // TODO: replace by filename, once we use the help more
ScriptBackend *backend;
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