summaryrefslogtreecommitdiff
path: root/include/framework
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-02-04 14:02:41 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-02-04 16:34:53 +0000
commit4904180247c0d5745a393e3cd57eaae29f3837e5 (patch)
treedcdc86ab3f80de6bed1a8d57fe3786084be625f3 /include/framework
parent0c3505f01a792449b0c6bf81f518e7a062eea146 (diff)
fix leak from framework::AddonMenuManager::BuildMenu
provide a callback when a menu item gets deleted Change-Id: I5b5f1a181fb10f53f6b1fe7b5637d385e1517530
Diffstat (limited to 'include/framework')
-rw-r--r--include/framework/menuconfiguration.hxx36
1 files changed, 30 insertions, 6 deletions
diff --git a/include/framework/menuconfiguration.hxx b/include/framework/menuconfiguration.hxx
index 885baae3cdeb..1a952f7330ce 100644
--- a/include/framework/menuconfiguration.hxx
+++ b/include/framework/menuconfiguration.hxx
@@ -61,22 +61,46 @@ class FWE_DLLPUBLIC MenuConfiguration
public:
struct Attributes
{
- Attributes()
- : nStyle(0)
+ private:
+ oslInterlockedCount refCount;
+
+ Attributes(const OUString& rFrame, const OUString& rImageIdStr)
+ : refCount(0)
+ , aTargetFrame(rFrame)
+ , aImageId(rImageIdStr)
+ , nStyle(0)
{
}
- Attributes( const OUString& aFrame, const OUString& aImageIdStr )
- : aTargetFrame(aFrame)
- , aImageId(aImageIdStr)
+ Attributes(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider)
+ : refCount(0)
+ , xDispatchProvider(rDispatchProvider)
, nStyle(0)
{
}
+ Attributes(const Attributes&); //not-implemented
+
+ public:
OUString aTargetFrame;
OUString aImageId;
- ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProvider > xDispatchProvider;
+ css::uno::WeakReference<css::frame::XDispatchProvider> xDispatchProvider;
sal_Int16 nStyle;
+
+ static sal_uIntPtr CreateAttribute(const OUString& rFrame, const OUString& rImageIdStr);
+ static sal_uIntPtr CreateAttribute(const css::uno::WeakReference<css::frame::XDispatchProvider>& rDispatchProvider);
+ static void ReleaseAttribute(sal_uIntPtr nAttributePtr);
+
+ void acquire()
+ {
+ osl_atomic_increment(&refCount);
+ }
+
+ void release()
+ {
+ if (!osl_atomic_decrement(&refCount))
+ delete this;
+ }
};
MenuConfiguration(