summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Barfurth <jb@openoffice.org>2001-07-20 09:58:46 +0000
committerJörg Barfurth <jb@openoffice.org>2001-07-20 09:58:46 +0000
commit4fa0240253759320fe66d908ca99e20e12896f59 (patch)
tree585f988e8ae6da4af1343282faa71071491276b4
parent668226633f1f519c278a9c7c1fab485135f3c6a0 (diff)
#89821# Need to keep element trees alive while sending notifications (after finishCommit)
-rw-r--r--configmgr/source/inc/roottree.hxx25
-rw-r--r--configmgr/source/treemgr/roottree.cxx29
2 files changed, 44 insertions, 10 deletions
diff --git a/configmgr/source/inc/roottree.hxx b/configmgr/source/inc/roottree.hxx
index 103601490336..ab4a52f8bdfa 100644
--- a/configmgr/source/inc/roottree.hxx
+++ b/configmgr/source/inc/roottree.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottree.hxx,v $
*
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:46 $
+ * last change: $Author: jb $ $Date: 2001-07-20 10:58:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,7 +62,14 @@
#ifndef CONFIGMGR_ROOTTREE_HXX_
#define CONFIGMGR_ROOTTREE_HXX_
-#include <vector>
+#ifndef CONFIGMGR_API_APITYPES_HXX_
+#include "apitypes.hxx" // for NotCopyable ...
+#endif
+
+#ifndef INCLUDED_MEMORY
+#include <memory>
+#define INCLUDED_MEMORY
+#endif
namespace configmgr
{
@@ -93,20 +100,28 @@ namespace configmgr
TemplateProvider const& aTemplateProvider);
//-----------------------------------------------------------------------------
- class CommitHelper
+ class CommitHelper : NotCopyable
{
- TreeImpl* m_pTree;
+ struct Data;
+
+ std::auto_ptr<Data> m_pData;
+ TreeImpl* m_pTree;
public:
CommitHelper(Tree const& aTree);
+ ~CommitHelper();
// collect all changes into rChangeList
bool prepareCommit(TreeChangeList& rChangeList);
+
// finish and clean up the changes in rChangeList after they are integrated
void finishCommit(TreeChangeList& rChangeList);
// restore the changes in rChangeList as pending
void revertCommit(TreeChangeList& rChangeList);
// throw away and clean up the changes in rChangeList after a commit failed
void failedCommit(TreeChangeList& rChangeList);
+
+ // dispose of auxiliary data for a commit operation
+ void reset();
};
//-----------------------------------------------------------------------------
diff --git a/configmgr/source/treemgr/roottree.cxx b/configmgr/source/treemgr/roottree.cxx
index 653b367400a2..bcefa2acdcfc 100644
--- a/configmgr/source/treemgr/roottree.cxx
+++ b/configmgr/source/treemgr/roottree.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: roottree.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: jb $ $Date: 2001-07-05 17:05:51 $
+ * last change: $Author: jb $ $Date: 2001-07-20 10:58:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -122,22 +122,41 @@ bool adjustToChanges( NodeChangesInformation& rLocalChanges,
//-----------------------------------------------------------------------------
// class CommitHelper
//-----------------------------------------------------------------------------
+struct CommitHelper::Data
+{
+ ElementList m_aRemovedElements; // filled to keep the elements alive 'till after notification
+};
+//-----------------------------------------------------------------------------
CommitHelper::CommitHelper(Tree const& aTree)
+: m_pData( )
+, m_pTree( TreeImplHelper::impl(aTree) )
{
- m_pTree = TreeImplHelper::impl(aTree);
OSL_ENSURE(m_pTree, "INTERNAL ERROR: Unexpected NULL tree in commit helper");
}
//-----------------------------------------------------------------------------
+CommitHelper::~CommitHelper()
+{
+}
+
+//-----------------------------------------------------------------------------
+void CommitHelper::reset()
+{
+ m_pData.reset();
+}
+//-----------------------------------------------------------------------------
bool CommitHelper::prepareCommit(TreeChangeList& rChangeList)
{
- OSL_ENSURE(m_pTree,"Cannot commit without a tree");
+ OSL_ENSURE(m_pTree,"ERROR: CommitHelper: Cannot commit without a tree");
if (m_pTree == NULL)
return false;
+ OSL_ENSURE(m_pData.get() == NULL,"ERROR: CommitHelper: Need to reset before reusing");
+ m_pData.reset( new Data() );
+
// get and check the changes
- std::auto_ptr<SubtreeChange> pTreeChange(m_pTree->preCommitChanges());
+ std::auto_ptr<SubtreeChange> pTreeChange(m_pTree->preCommitChanges(m_pData->m_aRemovedElements));
if (pTreeChange.get() == NULL)
return false;