Update of /cvsroot/mahogany/M/src/adb
In directory usw-pr-cvs1:/tmp/cvs-serv16172/src/adb
Modified Files:
ProvFC.cpp
Log Message:
fixed horrible bug (source of crashes and what not) in FCProv which could delete the
entry grandparent while the entry was still alive
Index: ProvFC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/ProvFC.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -b -u -2 -r1.33 -r1.34
--- ProvFC.cpp 15 Feb 2002 21:29:11 -0000 1.33
+++ ProvFC.cpp 28 Apr 2002 23:59:32 -0000 1.34
@@ -170,4 +170,33 @@
bool IsOk() const { return m_pConfig != NULL; }
+ // recursively call Inc/DecRef() on this group and all its parents: this is
+ // necessary to ensure that the group stays alive as long as it has any
+ // [grand] children
+ void IncRefRecursively()
+ {
+ FCEntryGroup *group = this;
+ do
+ {
+ // we can't use group->m_pParent after calling DecRef() on it as it
+ // might be already deleted then
+ FCEntryGroup *parent = group->m_pParent;
+ group->IncRef();
+ group = parent;
+ }
+ while ( group );
+ }
+
+ void DecRefRecursively()
+ {
+ FCEntryGroup *group = this;
+ do
+ {
+ FCEntryGroup *parent = group->m_pParent;
+ group->DecRef();
+ group = parent;
+ }
+ while ( group );
+ }
+
MOBJECT_DEBUG(FCEntryGroup)
@@ -300,5 +329,6 @@
Load(strValue);
}
- if(m_pGroup) m_pGroup->IncRef();
+
+ m_pGroup->IncRefRecursively();
m_bDirty = FALSE;
}
@@ -308,5 +338,6 @@
if ( m_bDirty )
Save();
- if(m_pGroup) m_pGroup->DecRef();
+
+ m_pGroup->DecRefRecursively();
}
@@ -500,8 +531,13 @@
}
}
+
+ if ( m_pParent )
+ m_pParent->IncRefRecursively();
}
FCEntryGroup::~FCEntryGroup()
{
+ if ( m_pParent )
+ m_pParent->DecRefRecursively();
}
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates