summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorArmin Le Grand <Armin.Le.Grand@cib.de>2018-07-27 16:04:07 +0200
committerArmin Le Grand <Armin.Le.Grand@cib.de>2018-07-30 17:52:30 +0200
commitf0dcfe008d58053e52c51b10e51c58eae27c1f0b (patch)
tree1e5b359120d501a7d4acb6051204c3ee5ce30add /include
parente1d73cb5552c2566c6d7463ce001e555523f3d92 (diff)
Added SdrObjectLifetimeWatchDog for debug mode
Change-Id: I79f65b7511d400c3e7071e45c3f0b1d385bcd8d4 Reviewed-on: https://gerrit.libreoffice.org/58197 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'include')
-rw-r--r--include/svx/svdmodel.hxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index ccc1323abe56..19cb27a3570b 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -49,6 +49,11 @@ class OutputDevice;
#include <rtl/ref.hxx>
#include <deque>
+#ifdef DBG_UTIL
+// SdrObjectLifetimeWatchDog
+#include <unordered_set>
+#endif
+
#define DEGREE_CHAR u'\x00B0' /* U+00B0 DEGREE SIGN */
class SdrOutliner;
@@ -152,6 +157,29 @@ struct SdrModelImpl;
class SVX_DLLPUBLIC SdrModel : public SfxBroadcaster, public virtual tools::WeakBase
{
+private:
+#ifdef DBG_UTIL
+ // SdrObjectLifetimeWatchDog:
+ // Use maAllIncarnatedObjects to keep track of all SdrObjects incarnated using this SdrModel
+ // (what is now possible after the paradigm change that a SdrObject stays at a single SdrModel
+ // for it's whole lifetime).
+ // The two methods are exclusive, debug-only, only-accessible-by SdrObject accesses to else
+ // hidden/non-existing maAllIncarnatedObjects.
+ // SdrObject::SdrObject uses impAddIncarnatedSdrObjectToSdrModel, while SdrObject::~SdrObject
+ // uses impRemoveIncarnatedSdrObjectToSdrModel.
+ // There are two places which may trigger OSL_FAIL warnings:
+ // - impRemoveIncarnatedSdrObjectToSdrModel when the to-be-removed SdrObject is not member of SdrModel
+ // - SdrModel::~SdrModel after all SdrObjects *should* be cleaned-up.
+ // SdrModel::~SdrModel will also - for convenience - Free the non-deleted SdrObjects if there
+ // are any.
+ // Using std::unordered_set will use quasi constant access times, so this watchdog will not
+ // be expensive. Nonetheless, only use with debug code. It may be seductive to use this in
+ // product code, too, especially if it will indeed trigger - but it's intention is clearly
+ // to find/identify MemoryLeaks caused by SdrObjects
+ friend void impAddIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
+ friend void impRemoveIncarnatedSdrObjectToSdrModel(const SdrObject& rSdrObject, SdrModel& rSdrModel);
+ std::unordered_set< const SdrObject* > maAllIncarnatedObjects;
+#endif
protected:
std::vector<SdrPage*> maMaPag; // master pages
std::vector<SdrPage*> maPages;