[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - extensions/source

Michael Meeks michael.meeks at collabora.com
Thu Jul 9 13:36:05 PDT 2015


 extensions/source/bibliography/bibview.cxx |    6 ++++--
 extensions/source/bibliography/general.cxx |    7 ++++---
 extensions/source/bibliography/general.hxx |    4 ++--
 3 files changed, 10 insertions(+), 7 deletions(-)

New commits:
commit e3e9684ef8974f4d0d4c72fdf24418d565a1e66b
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Thu Jul 9 12:58:11 2015 +0100

    tdf#92611 - unwind UNO lifecycle snafu.
    
    Introduced in commit 1c4025babd7037a3292aa530c7d45ab8d6ef6dcb.
    Was using UNO reference counting on a member allocated as part
    of another object.
    
    Change-Id: Ic86b2aa30359dc202c8bc2f1a0de476167a1e561
    Reviewed-on: https://gerrit.libreoffice.org/16889
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/16898
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/extensions/source/bibliography/bibview.cxx b/extensions/source/bibliography/bibview.cxx
index d1a8b95..23d4186 100644
--- a/extensions/source/bibliography/bibview.cxx
+++ b/extensions/source/bibliography/bibview.cxx
@@ -66,7 +66,7 @@ namespace bib
 
     void BibView::dispose()
     {
-        BibGeneralPage* pGeneralPage = m_pGeneralPage;
+        VclPtr<BibGeneralPage> pGeneralPage = m_pGeneralPage;
         m_pGeneralPage.clear();
 
         pGeneralPage->CommitActiveControl();
@@ -102,6 +102,7 @@ namespace bib
             m_aFormControlContainer.disconnectForm();
 
         pGeneralPage->RemoveListeners();
+        pGeneralPage.disposeAndClear();
         m_xGeneralPage = NULL;
         BibWindow::dispose();
     }
@@ -116,11 +117,12 @@ namespace bib
         {
             m_pGeneralPage->Hide();
             m_pGeneralPage->RemoveListeners();
+            m_pGeneralPage.disposeAndClear();
             m_xGeneralPage = 0;
         }
 
         m_pGeneralPage = VclPtr<BibGeneralPage>::Create( this, m_pDatMan );
-        m_xGeneralPage = &m_pGeneralPage->GetFocusListener();
+        m_xGeneralPage = m_pGeneralPage->GetFocusListener().get();
         m_pGeneralPage->Show();
 
         if( HasFocus() )
diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx
index f84ab58..19e8168 100644
--- a/extensions/source/bibliography/general.cxx
+++ b/extensions/source/bibliography/general.cxx
@@ -168,7 +168,7 @@ void BibPosListener::disposing(const lang::EventObject& /*Source*/) throw( uno::
 BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan):
     BibTabPage(pParent, "GeneralPage", "modules/sbibliography/ui/generalpage.ui"),
     sErrorPrefix(BIB_RESSTR(ST_ERROR_PREFIX)),
-    maBibGeneralPageFocusListener(this),
+    mxBibGeneralPageFocusListener(new BibGeneralPageFocusListener(this)),
     pDatMan(pMan)
 {
     get(pIdentifierFT, "shortname");
@@ -387,6 +387,7 @@ void BibGeneralPage::dispose()
     pCustom4FT.clear();
     pCustom5FT.clear();
     for (auto & a: aFixedTexts) a.clear();
+    mxBibGeneralPageFocusListener.clear();
     BibTabPage::dispose();
 }
 
@@ -397,7 +398,7 @@ void BibGeneralPage::RemoveListeners()
         if(aControls[i].is())
         {
             uno::Reference< awt::XWindow > xCtrWin(aControls[i], uno::UNO_QUERY );
-            xCtrWin->removeFocusListener( &maBibGeneralPageFocusListener );
+            xCtrWin->removeFocusListener( mxBibGeneralPageFocusListener.get() );
             aControls[i] = 0;
         }
     }
@@ -488,7 +489,7 @@ uno::Reference< awt::XControlModel >  BibGeneralPage::AddXControl(
                     // Peer as Child to the FrameWindow
                     xCtrlContnr->addControl(rName, xControl);
                     uno::Reference< awt::XWindow >  xCtrWin(xControl, UNO_QUERY );
-                    xCtrWin->addFocusListener( &maBibGeneralPageFocusListener );
+                    xCtrWin->addFocusListener( mxBibGeneralPageFocusListener.get() );
                     rIndex = -1;    // -> implies, that not found
                     for(sal_uInt16 i = 0; i < FIELD_COUNT; i++)
                         if(!aControls[i].is())
diff --git a/extensions/source/bibliography/general.hxx b/extensions/source/bibliography/general.hxx
index e566c9f..af34aa6 100644
--- a/extensions/source/bibliography/general.hxx
+++ b/extensions/source/bibliography/general.hxx
@@ -127,7 +127,7 @@ class BibGeneralPage: public BibTabPage
     ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >
                         xPosListener;
 
-    BibGeneralPageFocusListener maBibGeneralPageFocusListener;
+    rtl::Reference<BibGeneralPageFocusListener> mxBibGeneralPageFocusListener;
 
     BibDataManager*     pDatMan;
 
@@ -164,7 +164,7 @@ public:
 
     virtual bool                HandleShortCutKey( const KeyEvent& rKeyEvent ) SAL_OVERRIDE; // returns true, if key was handled
 
-    inline BibGeneralPageFocusListener& GetFocusListener() { return maBibGeneralPageFocusListener; }
+    inline rtl::Reference<BibGeneralPageFocusListener> GetFocusListener() { return mxBibGeneralPageFocusListener; }
 
     void focusGained(const css::awt::FocusEvent& rEvent) throw( css::uno::RuntimeException, std::exception );
     void focusLost(const css::awt::FocusEvent& rEvent) throw( css::uno::RuntimeException, std::exception );


More information about the Libreoffice-commits mailing list