[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : alex
Repository : xara
Revision : 954
Date : Thu May 4 20:16:38 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/dialogop.cpp
M /Trunk/XaraLX/Kernel/dialogop.h
Introduce a magic word into DialogOp which will check for errors due
to poor End() handling. Can't find any right now (which is very
surprising!).
Diff:
Index: Trunk/XaraLX/Kernel/dialogop.cpp
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.cpp (revision 953)
+++ Trunk/XaraLX/Kernel/dialogop.cpp (revision 954)
@@ -147,6 +147,22 @@
class Node;
struct ReDrawInfoType;
+#define MAGIC_CREATE 0xa1ec501dUL
+#define MAGIC_DESTROY 0xa1ecdeadUL
+
+#define CheckMagic(f) \
+ do \
+ { \
+ if (MagicWord == MAGIC_DESTROY) \
+ { \
+ ERROR3(f ": DialogOp already destroyed"); \
+ } \
+ else \
+ { \
+ ERROR3IF(MagicWord != MAGIC_CREATE, f ": DialogOp suffered double destroyed or is corrupt"); \
+ } \
+ } while(0)
+
//-----------------------------------------------------------------------------------------
DECLARE_SOURCE("$Revision$");
@@ -186,7 +202,9 @@
CCRuntimeClass* Class,
INT32 OpeningPage,
CWindowID ParentWnd) : Operation(Class)
-{
+{
+ MagicWord = MAGIC_CREATE; // Save this for later
+
DlgResID = DialogResID; // Dialog's resource ID
DlgMode = Mode; // Dialog's mode
SubDlgID = SubDialogID; // Dialog to merge with (0 => no merging)
@@ -320,6 +338,7 @@
void DialogOp::Close()
{
+ CheckMagic("DialogOp:Close()");
ENSURE(WindowID != NULL, "Trying to close a window with a NULL window ID !");
DlgMgr->Close(WindowID, this);
@@ -572,13 +591,16 @@
********************************************************************************************/
DialogOp::~DialogOp()
-{
+{
+ CheckMagic("DialogOp destructor");
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;
+
+ MagicWord = MAGIC_DESTROY;
}
// -----------------------------------------------------------------------------------------
@@ -2328,6 +2350,8 @@
MsgResult DialogOp::Message( Msg* Message )
{
+ CheckMagic("DialogOp::Message");;
+
if (MESSAGE_IS_A(Message, DocChangingMsg))
{
// Get a pointer the correct type of message.
@@ -2839,6 +2863,7 @@
CWindowID DialogOp::GetReadWriteWindowID()
{
+ CheckMagic("DialogOp::GetReadWriteWindowID");
return (DlgMgr->GetPageWindow(WindowID, ReadWritePage));
}
Index: Trunk/XaraLX/Kernel/dialogop.h
===================================================================
--- Trunk/XaraLX/Kernel/dialogop.h (revision 953)
+++ Trunk/XaraLX/Kernel/dialogop.h (revision 954)
@@ -521,6 +521,9 @@
BOOL AddDialogControlToHelper(CGadgetID GadgetID, CDlgResID PageID); // overridden for tabbed dialogs
BOOL RemoveDialogControlFromHelper(CGadgetID GadgetID);
BOOL RemoveDialogControlFromHelper(CGadgetID GadgetID , CDlgResID PageID);
+
+private:
+ UINT32 MagicWord;
};
Xara