[rkward-cvs] SF.net SVN: rkward: [792] trunk/rkward/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon Oct 2 19:24:51 UTC 2006


Revision: 792
          http://svn.sourceforge.net/rkward/?rev=792&view=rev
Author:   tfry
Date:     2006-10-02 12:24:42 -0700 (Mon, 02 Oct 2006)

Log Message:
-----------
Changing an edited object's type should not crash anymore

Modified Paths:
--------------
    trunk/rkward/rkward/core/rkmodificationtracker.cpp
    trunk/rkward/rkward/windows/rkworkplace.cpp
    trunk/rkward/rkward/windows/rkworkplace.h

Modified: trunk/rkward/rkward/core/rkmodificationtracker.cpp
===================================================================
--- trunk/rkward/rkward/core/rkmodificationtracker.cpp	2006-10-02 18:31:37 UTC (rev 791)
+++ trunk/rkward/rkward/core/rkmodificationtracker.cpp	2006-10-02 19:24:42 UTC (rev 792)
@@ -22,6 +22,7 @@
 #include "../rkglobals.h"
 #include "../dataeditor/rkeditor.h"
 #include "rcontainerobject.h"
+#include "../windows/rkworkplace.h"
 
 #include "../debug.h"
 
@@ -39,7 +40,7 @@
 bool RKModificationTracker::removeObject (RObject *object, RKEditor *editor, bool removed_in_workspace) {
 	RK_TRACE (OBJECTS);
 // TODO: allow more than one editor per object
-#warning ! This does not work, if a sub-object is being edited!
+// WARNING: This does not work, if a sub-object is being edited!
 	RKEditor *ed = object->objectOpened ();
 	RK_ASSERT (!((editor) && (!ed)));
 	RK_ASSERT (!(removed_in_workspace && editor));
@@ -64,7 +65,19 @@
 		}
 	}
 	
-	if (ed) ed->removeObject (object);
+	if (ed) ed->removeObject (object);		// READ: delete ed
+/* What's this? A child of a removed complex object may be edited somewhere, but not the whole object. In this case, the editor has no chance of restoring the object, but it still needs to be closed. We search all editors for the removed object */
+	if (object->isContainer ()) {
+		RKWorkplace::RKWorkplaceObjectList list = RKWorkplace::mainWorkplace ()->getObjectList (RKMDIWindow::DataEditorWindow);
+		for (RKWorkplace::RKWorkplaceObjectList::const_iterator it = list.constBegin (); it != list.constEnd (); ++it) {
+			RKEditor *subed = static_cast<RKEditor *> (*it);
+			RObject *subedobj = subed->getObject ();
+			if (static_cast<RContainerObject *> (object)->isParentOf (subedobj, true)) {
+				subed->removeObject (subedobj);
+			}
+		}
+	}
+
 	if (updates_locked <= 0) emit (objectRemoved (object));
 	object->remove (removed_in_workspace);
 

Modified: trunk/rkward/rkward/windows/rkworkplace.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.cpp	2006-10-02 18:31:37 UTC (rev 791)
+++ trunk/rkward/rkward/windows/rkworkplace.cpp	2006-10-02 19:24:42 UTC (rev 792)
@@ -207,16 +207,22 @@
 	else RK_ASSERT (false);		// this is benign, and maybe even ok, but I'd like to see when this happens
 }
 
-void RKWorkplace::closeAll (int type, int state) {
+RKWorkplace::RKWorkplaceObjectList RKWorkplace::getObjectList (int type, int state) {
 	RK_TRACE (APP);
 
-	RKWorkplaceObjectList list_to_close;
+	RKWorkplaceObjectList ret;
 	for (RKWorkplaceObjectList::const_iterator it = windows.constBegin (); it != windows.constEnd (); ++it) {
 		if (((*it)->type & type) && ((*it)->state & state)) {
-			list_to_close.append ((*it));		// can't inline deletion
+			ret.append ((*it));
 		}
 	}
+	return ret;
+}
 
+void RKWorkplace::closeAll (int type, int state) {
+	RK_TRACE (APP);
+
+	RKWorkplaceObjectList list_to_close = getObjectList (type, state);
 	for (RKWorkplaceObjectList::const_iterator it = list_to_close.constBegin (); it != list_to_close.constEnd (); ++it) {
 		closeWindow (*it);
 	}

Modified: trunk/rkward/rkward/windows/rkworkplace.h
===================================================================
--- trunk/rkward/rkward/windows/rkworkplace.h	2006-10-02 18:31:37 UTC (rev 791)
+++ trunk/rkward/rkward/windows/rkworkplace.h	2006-10-02 19:24:42 UTC (rev 792)
@@ -49,6 +49,8 @@
 	typedef QValueList<RKMDIWindow *> RKWorkplaceObjectList;
 /** Returns a list of all windows in the workplace. */
 	RKWorkplaceObjectList getObjectList () { return windows; };
+/** Returns a list of all windows with a given type and state */
+	RKWorkplaceObjectList getObjectList (int type, int state=RKMDIWindow::AnyState);
 
 /** Attach an already created window. */
 	void attachWindow (RKMDIWindow *window);


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