include/sfx2/sidebar/SidebarController.hxx | 5 ++++- sfx2/source/sidebar/SidebarController.cxx | 24 +++++++++++++++++------- sfx2/source/sidebar/SidebarDockingWindow.cxx | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-)
New commits: commit 8a71eacef77c5b45df0078b92893e69b1140bac2 Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Dec 20 14:13:13 2016 +0100 Don't use 'this' in ctor Change-Id: I405160743609aae92a37b2359bea5aa42ee66519 diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index 7aaefc1..519daef 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -65,7 +65,7 @@ class SFX2_DLLPUBLIC SidebarController public SidebarControllerInterfaceBase { public: - SidebarController( + static rtl::Reference<SidebarController> create( SidebarDockingWindow* pParentWindow, const css::uno::Reference<css::frame::XFrame>& rxFrame); virtual ~SidebarController() override; @@ -163,6 +163,9 @@ public: void FadeOut(); private: + SidebarController( + SidebarDockingWindow* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame); VclPtr<Deck> mpCurrentDeck; VclPtr<SidebarDockingWindow> mpParentWindow; diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index eb5cad7..f048a7a 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -116,24 +116,34 @@ SidebarController::SidebarController ( { // Decks and panel collections for this sidebar mpResourceManager = o3tl::make_unique<ResourceManager>(); +} + +rtl::Reference<SidebarController> SidebarController::create( + SidebarDockingWindow* pParentWindow, + const css::uno::Reference<css::frame::XFrame>& rxFrame) +{ + rtl::Reference<SidebarController> instance( + new SidebarController(pParentWindow, rxFrame)); - registerSidebarForFrame(this, mxFrame->getController()); + registerSidebarForFrame(instance.get(), rxFrame->getController()); // Listen for window events. - mpParentWindow->AddEventListener(LINK(this, SidebarController, WindowEventHandler)); + instance->mpParentWindow->AddEventListener(LINK(instance.get(), SidebarController, WindowEventHandler)); // Listen for theme property changes. Theme::GetPropertySet()->addPropertyChangeListener( "", - static_cast<css::beans::XPropertyChangeListener*>(this)); + static_cast<css::beans::XPropertyChangeListener*>(instance.get())); // Get the dispatch object as preparation to listen for changes of // the read-only state. const util::URL aURL (Tools::GetURL(gsReadOnlyCommandName)); - mxReadOnlyModeDispatch = Tools::GetDispatch(mxFrame, aURL); - if (mxReadOnlyModeDispatch.is()) - mxReadOnlyModeDispatch->addStatusListener(this, aURL); + instance->mxReadOnlyModeDispatch = Tools::GetDispatch(rxFrame, aURL); + if (instance->mxReadOnlyModeDispatch.is()) + instance->mxReadOnlyModeDispatch->addStatusListener(instance.get(), aURL); - SwitchToDeck(gsDefaultDeckId); + instance->SwitchToDeck(gsDefaultDeckId); + + return instance; } SidebarController::~SidebarController() diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx index e767731..84a2834 100644 --- a/sfx2/source/sidebar/SidebarDockingWindow.cxx +++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx @@ -44,7 +44,7 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi { const SfxViewFrame* pViewFrame = pSfxBindings->GetDispatcher()->GetFrame(); const SfxFrame& rFrame = pViewFrame->GetFrame(); - mpSidebarController.set(new sfx2::sidebar::SidebarController(this, rFrame.GetFrameInterface())); + mpSidebarController.set(sfx2::sidebar::SidebarController::create(this, rFrame.GetFrameInterface()).get()); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits