[rkward-cvs] SF.net SVN: rkward: [2206] branches/KDE4_port/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Nov 12 16:37:01 UTC 2007


Revision: 2206
          http://rkward.svn.sourceforge.net/rkward/?rev=2206&view=rev
Author:   tfry
Date:     2007-11-12 08:37:01 -0800 (Mon, 12 Nov 2007)

Log Message:
-----------
Don't crash when restoring edited object, and auto-close editor, if the object is gone for good.

Modified Paths:
--------------
    branches/KDE4_port/rkward/core/rcontainerobject.h
    branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
    branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp
    branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp
    branches/KDE4_port/rkward/dataeditor/rkvareditmodel.h
    branches/KDE4_port/rkward/dataeditor/twintable.cpp

Modified: branches/KDE4_port/rkward/core/rcontainerobject.h
===================================================================
--- branches/KDE4_port/rkward/core/rcontainerobject.h	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/core/rcontainerobject.h	2007-11-12 16:37:01 UTC (rev 2206)
@@ -73,6 +73,11 @@
 	void findObjectsMatching (const QString &partial_name, RObjectSearchMap *current_list, bool name_is_canonified=false) const;
 
 	void moveChild (RObject* child, int from_index, int to_index);
+
+	/** reimplemented from RObject to do nothing at all, including not raising an assert. This is because container objects do not have any edit data, themselves, but may be opened for editing, e.g. as a data.frame */
+	void beginEdit () {};
+	/** see beginEdit() */
+	void endEdit () {};
 protected:
 	void updateChildren (RData *new_children);
 	RObjectMap childmap;

Modified: branches/KDE4_port/rkward/core/rkmodificationtracker.cpp
===================================================================
--- branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/core/rkmodificationtracker.cpp	2007-11-12 16:37:01 UTC (rev 2206)
@@ -64,7 +64,9 @@
 	if (removed_in_workspace) {
 		if (ed) {
 			if (KMessageBox::questionYesNo (0, i18n ("The object '%1' was removed from workspace or changed to a different type of object, but is currently opened for editing. Do you want to restore it?", object->getFullName ()), i18n ("Restore object?")) == KMessageBox::Yes) {
-				if (removed_in_workspace) ed->restoreObject (object);
+qDebug ("a");
+				ed->restoreObject (object);
+qDebug ("b");
 				return false;
 			}
 		}

Modified: branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/dataeditor/rkeditordataframe.cpp	2007-11-12 16:37:01 UTC (rev 2206)
@@ -48,6 +48,7 @@
 
 	RKVarEditDataFrameModel* model = new RKVarEditDataFrameModel (object, this);
 	initTable (model, object);
+	connect (model, SIGNAL (modelObjectDestroyed()), this, SLOT (deleteLater()));
 
 	waitForLoad ();
 }
@@ -66,6 +67,7 @@
 	RK_ASSERT (object->isDataFrame ());
 
 	initTable (model, object);
+	connect (model, SIGNAL (modelObjectDestroyed()), this, SLOT (deleteLater()));
 
 	RKGlobals::rInterface ()->closeChain (open_chain);
 }

Modified: branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/dataeditor/rkvareditmodel.cpp	2007-11-12 16:37:01 UTC (rev 2206)
@@ -81,9 +81,7 @@
 	if (meta_model) meta_model->endRemoveDataObject ();
 	endRemoveColumns ();
 
-	if (objects.isEmpty ()) {
-#warning TODO notify editor
-	}
+	if (objects.isEmpty ()) emit (modelDepleted ());	// editor may or may want to auto-destruct
 }
 
 void RKVarEditModel::objectMetaChanged (RObject* changed) {
@@ -782,12 +780,15 @@
 
 	if (object == dataframe) {
 		while (!objects.isEmpty ()) RKVarEditModel::objectRemoved (objects[0]);
-#warning TODO: notify editor
 		stopListenForObject (dataframe);
 		dataframe = 0;
 	}
 
 	RKVarEditModel::objectRemoved (object);
+
+	// if the dataframe is gone, the editor will most certainly want to auto-destruct.
+	// since the model will be taken down as well, this has to come last in the function.
+	if (!dataframe) emit (modelObjectDestroyed ());
 }
 
 void RKVarEditDataFrameModel::childAdded (int index, RObject* parent) {

Modified: branches/KDE4_port/rkward/dataeditor/rkvareditmodel.h
===================================================================
--- branches/KDE4_port/rkward/dataeditor/rkvareditmodel.h	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/dataeditor/rkvareditmodel.h	2007-11-12 16:37:01 UTC (rev 2206)
@@ -87,6 +87,8 @@
 	void objectDataChanged (RObject* object, const RObject::ChangeSet *changes);
 
 	RKVariable* getObject (int index) const;
+signals:
+	void modelDepleted ();
 protected:
 friend class RKVarEditMetaModel;
 	QList<RKVariable*> objects;
@@ -176,6 +178,8 @@
 	RContainerObject* getObject () const { return dataframe; };
 
 	void restoreObject (RObject* object, RCommandChain* chain);
+signals:
+	void modelObjectDestroyed ();
 protected:
 	void doInsertColumns (int index, int count);
 	/** reimplemented from RKVarEditModel to listen for the dataframe object as well */

Modified: branches/KDE4_port/rkward/dataeditor/twintable.cpp
===================================================================
--- branches/KDE4_port/rkward/dataeditor/twintable.cpp	2007-11-12 16:12:53 UTC (rev 2205)
+++ branches/KDE4_port/rkward/dataeditor/twintable.cpp	2007-11-12 16:37:01 UTC (rev 2206)
@@ -97,6 +97,7 @@
 	datamodel = model;
 	dataview->setRKModel (model);
 	metaview->setRKModel (model->getMetaModel ());
+	model->setEditor (this);
 	dataview->seRKItemDelegate (new RKItemDelegate (this, datamodel));
 	metaview->seRKItemDelegate (new RKItemDelegate (this, datamodel->getMetaModel ()));
 


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