[rkward-cvs] SF.net SVN: rkward:[2904] trunk/rkward/rkward/dataeditor
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Sun Jun 27 10:34:00 UTC 2010
Revision: 2904
http://rkward.svn.sourceforge.net/rkward/?rev=2904&view=rev
Author: tfry
Date: 2010-06-27 10:34:00 +0000 (Sun, 27 Jun 2010)
Log Message:
-----------
Do not crash when edited data.frame is removed, and user chooses not to restore it
Modified Paths:
--------------
trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
trunk/rkward/rkward/dataeditor/rkeditordataframe.h
trunk/rkward/rkward/dataeditor/rkvareditmodel.cpp
Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp 2010-06-26 10:45:24 UTC (rev 2903)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.cpp 2010-06-27 10:34:00 UTC (rev 2904)
@@ -48,7 +48,7 @@
RKVarEditDataFrameModel* model = new RKVarEditDataFrameModel (object, this);
initTable (model, object);
- connect (model, SIGNAL (modelObjectDestroyed()), this, SLOT (deleteLater()));
+ connect (model, SIGNAL (modelObjectDestroyed()), this, SLOT (detachModel()));
waitForLoad ();
}
@@ -86,6 +86,14 @@
RK_TRACE (EDITOR);
}
+void RKEditorDataFrame::detachModel () {
+ RK_TRACE (EDITOR);
+
+ dataview->setRKModel (0);
+ metaview->setRKModel (0);
+ deleteLater ();
+}
+
void RKEditorDataFrame::flushChanges () {
RK_TRACE (EDITOR);
flushEdit ();
@@ -118,3 +126,5 @@
#warning TODO: this interface should be moved to the model for good.
datamodel->restoreObject (object, 0);
}
+
+#include "rkeditordataframe.moc"
Modified: trunk/rkward/rkward/dataeditor/rkeditordataframe.h
===================================================================
--- trunk/rkward/rkward/dataeditor/rkeditordataframe.h 2010-06-26 10:45:24 UTC (rev 2903)
+++ trunk/rkward/rkward/dataeditor/rkeditordataframe.h 2010-06-27 10:34:00 UTC (rev 2904)
@@ -31,6 +31,7 @@
@author Thomas Friedrichsmeier
*/
class RKEditorDataFrame : public TwinTable, public RCommandReceiver {
+ Q_OBJECT
public:
/** constructor.
@param object an existing R object
@@ -47,6 +48,8 @@
/** Tells the editor to restore the given object in the R-workspace from its copy of the data */
void restoreObject (RObject *object);
+private slots:
+ void detachModel ();
private:
/// syncs the whole table.
void pushTable (RCommandChain *sync_chain);
Modified: trunk/rkward/rkward/dataeditor/rkvareditmodel.cpp
===================================================================
--- trunk/rkward/rkward/dataeditor/rkvareditmodel.cpp 2010-06-26 10:45:24 UTC (rev 2903)
+++ trunk/rkward/rkward/dataeditor/rkvareditmodel.cpp 2010-06-27 10:34:00 UTC (rev 2904)
@@ -80,8 +80,9 @@
int index = objects.indexOf (static_cast<RKVariable*> (object)); // no check for isVariable needed. we only need to look up, if we have this object, and where.
if (index < var_col_offset) {
- RK_ASSERT (index < 0); // some unrelated object
- return;
+ if (index < 0) return; // e.g. the data.frame object
+ // the rownames object should only be deleted, when the whole data.frame is gone)
+ RK_ASSERT (objects.size () <= var_col_offset);
}
beginRemoveColumns (QModelIndex (), index, index);
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