diff options
author | Jörg Barfurth <jb@openoffice.org> | 2002-12-03 11:29:27 +0000 |
---|---|---|
committer | Jörg Barfurth <jb@openoffice.org> | 2002-12-03 11:29:27 +0000 |
commit | 10e892e7f8f944d3c67f286d2ade807b5d837e0d (patch) | |
tree | 84abd79b966f08c1452bf5ce84d2bc2508ca97c7 /unotools | |
parent | cac422318e349ca5003df868ac04408c8f317448 (diff) |
#105579# Add new mode to propagate construction errors
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/configitem.hxx | 7 | ||||
-rw-r--r-- | unotools/source/config/configitem.cxx | 36 |
2 files changed, 37 insertions, 6 deletions
diff --git a/unotools/inc/unotools/configitem.hxx b/unotools/inc/unotools/configitem.hxx index 9c8c237a01ed..edd80e566471 100644 --- a/unotools/inc/unotools/configitem.hxx +++ b/unotools/inc/unotools/configitem.hxx @@ -2,9 +2,9 @@ * * $RCSfile: configitem.hxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: os $ $Date: 2002-09-25 07:58:44 $ + * last change: $Author: jb $ $Date: 2002-12-03 12:29:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,7 +96,8 @@ namespace utl #define CONFIG_MODE_DELAYED_UPDATE 0x01 #define CONFIG_MODE_ALL_LOCALES 0x02 #define CONFIG_MODE_RELEASE_TREE 0x04 -#define CONFIG_MODE_IGNORE_ERRORS 0x08 //prevent assertions +#define CONFIG_MODE_IGNORE_ERRORS 0x08 // prevent assertions, if creation fails +#define CONFIG_MODE_PROPAGATE_ERRORS 0x10 // throw exceptions, if creation fails enum ConfigNameFormat { diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index a0d43c0b5a23..59905c3fff68 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -2,9 +2,9 @@ * * $RCSfile: configitem.cxx,v $ * - * $Revision: 1.37 $ + * $Revision: 1.38 $ * - * last change: $Author: os $ $Date: 2002-09-25 07:51:42 $ + * last change: $Author: jb $ $Date: 2002-12-03 12:29:27 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -199,6 +199,30 @@ public: rCnt--; } }; +/* -----------------------------03.12.02 ------------------------------------- + + ---------------------------------------------------------------------------*/ +namespace +{ + // helper to achieve exception - safe handling of an Item under construction + template <class TYP> + class AutoDeleter // : Noncopyable + { + TYP* pItem; + public: + AutoDeleter(TYP * pItem) + : pItem(pItem) + { + } + + ~AutoDeleter() + { + delete pItem; + } + + void keep() { pItem = 0; } + }; +} /* -----------------------------29.08.00 16:34-------------------------------- ---------------------------------------------------------------------------*/ @@ -268,12 +292,18 @@ ConfigItem::ConfigItem(const OUString rSubTree, sal_Int16 nSetMode ) : pImpl(new ConfigItem_Impl), sSubTree(rSubTree) { + AutoDeleter<ConfigItem_Impl> aNewImpl(pImpl); + pImpl->pManager = ConfigManager::GetConfigManager(); pImpl->nMode = nSetMode; if(0 != (nSetMode&CONFIG_MODE_RELEASE_TREE)) pImpl->pManager->AddConfigItem(*this); else m_xHierarchyAccess = pImpl->pManager->AddConfigItem(*this); + + // no more exceptions after c'tor has finished + aNewImpl.keep(); + pImpl->nMode &= ~CONFIG_MODE_PROPAGATE_ERRORS; } /* -----------------------------17.11.00 13:53-------------------------------- @@ -283,7 +313,7 @@ ConfigItem::ConfigItem(utl::ConfigManager& rManager, const rtl::OUString rSubTr sSubTree(rSubTree) { pImpl->pManager = &rManager; - pImpl->nMode = CONFIG_MODE_IMMEDIATE_UPDATE; + pImpl->nMode = CONFIG_MODE_IMMEDIATE_UPDATE; // does not allow exceptions m_xHierarchyAccess = pImpl->pManager->AddConfigItem(*this); } //--------------------------------------------------------------------- |