[rkward-cvs] [rkward] /: Don't rely on an active plugins component handle to persist (it will be deleted, and may or may not be recreated when reloading pluginmaps).

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Jan 5 21:24:59 UTC 2015


Git commit 90304e9907a53a0f5472a42e9f7997d0d43afda1 by Thomas Friedrichsmeier.
Committed on 05/01/2015 at 21:24.
Pushed by tfry into branch 'master'.

Don't rely on an active plugins component handle to persist (it will be deleted, and may or may not be recreated when reloading pluginmaps).

M  +0    -1    ChangeLog
M  +1    -1    rkward/plugin/rkcomponentmap.cpp
M  +6    -3    rkward/plugin/rkstandardcomponent.cpp
M  +5    -5    rkward/plugin/rkstandardcomponent.h
M  +4    -6    rkward/plugin/rkstandardcomponentgui.cpp

http://commits.kde.org/rkward/90304e9907a53a0f5472a42e9f7997d0d43afda1

diff --git a/ChangeLog b/ChangeLog
index 5960d9d..76743f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,5 @@
 - Fix a hang-on-exit issue
 - Add R function rk.set.plugin.status() to allow further customization of loaded plugins (hiding of individual menu entries)
-  - TODO: With the improved interface to plugins from R, make sure plugins can actually be modified at runtime without crashing (close and re-open them)
 - Pluginmap-management was reworked, partially, and moved to Settings->Manage R packages and plugins
 - Provide more detailed information on loaded plugins in rk.list.plugins()
 - Allow to override plugins from a different pluginmap (the plugin with the highest specified version is used)
diff --git a/rkward/plugin/rkcomponentmap.cpp b/rkward/plugin/rkcomponentmap.cpp
index 5ed7cf7..e9128b9 100644
--- a/rkward/plugin/rkcomponentmap.cpp
+++ b/rkward/plugin/rkcomponentmap.cpp
@@ -793,7 +793,7 @@ RKComponentHandle::~RKComponentHandle () {
 RKStandardComponent *RKComponentHandle::invoke (RKComponent *parent_component, QWidget *parent_widget) {
 	RK_TRACE (PLUGIN);
 
-	return (new RKStandardComponent (parent_component, parent_widget, getFilename (), this));
+	return (new RKStandardComponent (parent_component, parent_widget, getFilename (), RKComponentMap::getComponentId (this)));
 }
 
 QString RKComponentHandle::getAttributeValue (const QString &attribute_id) {
diff --git a/rkward/plugin/rkstandardcomponent.cpp b/rkward/plugin/rkstandardcomponent.cpp
index c28b389..0902499 100644
--- a/rkward/plugin/rkstandardcomponent.cpp
+++ b/rkward/plugin/rkstandardcomponent.cpp
@@ -64,11 +64,11 @@
 #include "../debug.h"
 
 
-RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget *parent_widget, const QString &filename, RKComponentHandle *handle) : RKComponent (parent_component, parent_widget) {
+RKStandardComponent::RKStandardComponent (RKComponent *parent_component, QWidget *parent_widget, const QString &filename, const QString &id) : RKComponent (parent_component, parent_widget) {
 	RK_TRACE (PLUGIN);
 
 	RKStandardComponent::filename = filename;
-	RKStandardComponent::handle = handle;
+	RKStandardComponent::id = id;
 	command_chain = 0;
 	backend = 0;
 	scripting = 0;
@@ -225,7 +225,10 @@ void RKStandardComponent::setCaption (const QString &caption) {
 XMLHelper* RKStandardComponent::getXmlHelper () {
 	RK_TRACE (PLUGIN);
 
-	if (!xml) xml = new XMLHelper (filename, getHandle ()->messageCatalog ());
+	if (!xml) {
+		RKComponentHandle *handle = RKComponentMap::getComponentHandle (id);
+		xml = new XMLHelper (filename, handle ? handle->messageCatalog () : 0);
+	}
 	return xml;
 }
 
diff --git a/rkward/plugin/rkstandardcomponent.h b/rkward/plugin/rkstandardcomponent.h
index 325eb57..7671016 100644
--- a/rkward/plugin/rkstandardcomponent.h
+++ b/rkward/plugin/rkstandardcomponent.h
@@ -41,7 +41,7 @@ public:
 @param parent_component Parent component (or 0, if this is going to be a top-level component)
 @param parent_widget Parent widget (typically 0, if this is going to be a top-level component)
 @param filename Filename of the XML-file to construct this component from */
-	RKStandardComponent (RKComponent *parent_component, QWidget *parent_widget, const QString &filename, RKComponentHandle *handle);
+	RKStandardComponent (RKComponent *parent_component, QWidget *parent_widget, const QString &filename, const QString &id);
 /** destructor */
 	~RKStandardComponent ();
 /** reimplemented to update code on changes*/
@@ -65,10 +65,10 @@ public:
 /** set the GUI caption (if this is a top-level gui) */
 	void setCaption (const QString &caption);
 /** return the filename of the xml file */
-	QString getFilename () { return filename; };
+	QString getFilename () const { return filename; };
 	XMLHelper *getXmlHelper ();
-	RKComponentHandle *getHandle () { return handle; };
-	bool haveHelp () { return have_help; };
+	QString getId () const { return id; };
+	bool haveHelp () const { return have_help; };
 /** Submits the current code (by simulating a click on the ok button).
 @param in_chain The command chain to insert the command in (0 for regular command stack).
 @return false, if the plugin-code could not be submitted (e.g. plugin was not satisfied) */
@@ -109,7 +109,7 @@ private:
 	ScriptBackend *backend;
 	RKComponentScriptingProxy* scripting;
 	RKStandardComponentGUI *gui;
-	RKComponentHandle *handle;
+	QString id;
 	RKStandardComponentStack *wizard;
 	bool update_pending;
 	RCommandChain *command_chain;
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 79d6884..b4a45b9 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -171,11 +171,11 @@ void RKStandardComponentGUI::ok () {
 	// re-run link
 	// This should be run in a separate command, in case the above command bails out with an error. Even in that case, the re-run link should be printed.
 	command.clear ();
-	RKComponentHandle *handle = component->getHandle ();
-	if (handle->isAccessible ()) {
+	RKComponentHandle *handle = RKComponentMap::getComponentHandle (component->getId ());
+	if (handle && handle->isAccessible ()) {
 		RKComponent::PropertyValueMap map;
 		component->serializeState (&map);
-		command.append (".rk.rerun.plugin.link(plugin=\"" + RKComponentMap::getComponentId (handle) + "\", settings=\"" + RKCommonFunctions::escape (RKComponent::valueMapToString (map)) + "\", label=\"" + i18n ("Run again") + "\")\n");
+		command.append (".rk.rerun.plugin.link(plugin=\"" + component->getId () + "\", settings=\"" + RKCommonFunctions::escape (RKComponent::valueMapToString (map)) + "\", label=\"" + i18n ("Run again") + "\")\n");
 		// NOTE: the serialized state is quote-escape *again* for passing to R.
 	}
 	// separator line
@@ -225,9 +225,7 @@ void RKStandardComponentGUI::copyCode () {
 void RKStandardComponentGUI::help () {
 	RK_TRACE (PLUGIN);
 
-	QString id = RKComponentMap::getComponentId (component->getHandle ());
-
-	QString path = id.split ("::").join ("/");
+	QString path = component->getId ().split ("::").join ("/");
 	RKWorkplace::mainWorkplace ()->openHelpWindow (KUrl ("rkward://component/" + path));
 }
 





More information about the rkward-tracker mailing list