[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : alex
Repository : xara
Revision   : 935
Date       : Tue May  2 16:07:23 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/aligndlg.cpp
   M /Trunk/XaraLX/Kernel/appprefs.cpp
   M /Trunk/XaraLX/Kernel/dialogop.cpp

Another attempt to fix bug 933. The problem was that the Align Dialogs
End() operator (which deletes it) was being called in the message processor,
and THEN the message was being passed onto the base class. This is dangerous as the "this" pointer is invalid. Amazingly, this worked on the Debug build because the IS_OUR_DIALOG macro failed, as on the debug build, objects are wiped with crud automatically when destroyed. However, on the retail build, the object was not wiped and thus the WindowID matched up. This then called Close() which failed nastilly as the window destruction routine had destroyed (and nulled) the window's pEvtHandler.

The solution here is not to call the base class's message processor if the object has been destroyed. Or (in this case) to leave the destruction to the base class handler and not attempt to do it in the main dialog. One or the other, but not both...


Diff:
Index: Trunk/XaraLX/Kernel/aligndlg.cpp
===================================================================
--- Trunk/XaraLX/Kernel/aligndlg.cpp	(revision 934)
+++ Trunk/XaraLX/Kernel/aligndlg.cpp	(revision 935)
@@ -373,8 +373,8 @@
 				break;
 
 			case DIM_CANCEL:				// handle cancel
-				Close();
-				End();
+				// Close();
+				// End(); // Do not call Close() and End(). The base class does this.
 				break;
 
 			default:
Index: Trunk/XaraLX/Kernel/appprefs.cpp
===================================================================
--- Trunk/XaraLX/Kernel/appprefs.cpp	(revision 934)
+++ Trunk/XaraLX/Kernel/appprefs.cpp	(revision 935)
@@ -966,6 +966,7 @@
 			if (!ok)
 			{
 				EndDialog = FALSE;	// Values not correct so do not allow exit
+				Msg->DlgMsg = DIM_SOFT_COMMIT; // turn the message into a soft-commit so the base class does not destroy the dialog
 			}
 
 #ifndef REMOVE_PRINT_TABS
@@ -1009,20 +1010,16 @@
 
 		// Allow the base class access to the message, it will do the
 		// DLG_EAT_IF_HUNGRY(Msg) for us
-		// Must do this before the Close and End
+		// Note that this call can DELETE "this"
 		Result = DialogTabOp::Message(Message);
 
 		// End dialog here
 		if (EndDialog) 
 		{
-			Close();				// Hide the dialog box
-			End();					// Finish the operation
-
 			// Make sure that we remove our options tabs link to the dialog box class
 			// as the dialog will now be destroyed
 			OptionsTabs::pPrefsDlg = NULL;
 		}
-
 		
 		// Check if have been sending an init/create message and if so then set flag False.
 		// Only do this in the init/create case as we might be sent one of these and then
Index: Trunk/XaraLX/Kernel/dialogop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.cpp	(revision 934)
+++ Trunk/XaraLX/Kernel/dialogop.cpp	(revision 935)
@@ -576,6 +576,8 @@
 	if (WindowID != NULL)
 		DlgMgr->Delete(WindowID, this); 
 
+	WindowID = NULL; // ensure we get a NULL pointer if this is used again
+	DlgMgr = NULL;	// Again, ensure this is a NULL pointer
 	pEvtHandler=NULL;
 }    
 


Xara