[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sfx2/inc sfx2/source

Andre Fischer af at apache.org
Wed Mar 12 09:08:04 PDT 2014


 sfx2/inc/sfx2/sidebar/SidebarChildWindow.hxx |    1 +
 sfx2/inc/sfx2/templdlg.hxx                   |    2 +-
 sfx2/source/dialog/templdlg.cxx              |   26 +++++++++++++++++++++-----
 sfx2/source/inc/templdgi.hxx                 |    2 +-
 sfx2/source/sidebar/SidebarChildWindow.cxx   |    7 +++++++
 sfx2/source/sidebar/SidebarDockingWindow.cxx |    6 ++++++
 6 files changed, 37 insertions(+), 7 deletions(-)

New commits:
commit 952f581cb77f52e9aaa974496dc8d86b335cb424
Author: Andre Fischer <af at apache.org>
Date:   Wed Mar 12 14:21:27 2014 +0000

    124392: Avoid crash on close after assigning style.

diff --git a/sfx2/inc/sfx2/sidebar/SidebarChildWindow.hxx b/sfx2/inc/sfx2/sidebar/SidebarChildWindow.hxx
index 4562f41..b41e907 100644
--- a/sfx2/inc/sfx2/sidebar/SidebarChildWindow.hxx
+++ b/sfx2/inc/sfx2/sidebar/SidebarChildWindow.hxx
@@ -42,6 +42,7 @@ public:
         sal_uInt16 nId,
         SfxBindings* pBindings,
         SfxChildWinInfo* pInfo);
+    virtual ~SidebarChildWindow (void);
 
     SFX_DECL_CHILDWINDOW(SidebarChildWindow);
 
diff --git a/sfx2/inc/sfx2/templdlg.hxx b/sfx2/inc/sfx2/templdlg.hxx
index e86e458..e8b9cb9 100644
--- a/sfx2/inc/sfx2/templdlg.hxx
+++ b/sfx2/inc/sfx2/templdlg.hxx
@@ -100,7 +100,7 @@ class SFX2_DLLPUBLIC SfxTemplatePanelControl : public DockingWindow
 {
 public:
     SfxTemplatePanelControl (SfxBindings* pBindings, Window* pParentWindow);
-    ~SfxTemplatePanelControl (void);
+    virtual ~SfxTemplatePanelControl (void);
 
     virtual void                Update();
     virtual void                DataChanged( const DataChangedEvent& _rDCEvt );
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index e2754ad..3490510 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1849,16 +1849,36 @@ sal_Bool SfxCommonTemplateDialog_Impl::Execute_Impl(
 
     pItems[ nCount++ ] = 0;
 
+    // This unbelievably crude technique is used to detect and handle
+    // destruction of this during the synchronous slot call: store a
+    // pointer to a local bool, initialize it to false and set that it
+    // to true in the destructor.
     Deleted aDeleted;
     pbDeleted = &aDeleted;
+
     sal_uInt16 nModi = pModifier ? *pModifier : 0;
     const SfxPoolItem* pItem = rDispatcher.Execute(
         nId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
         pItems, nModi );
 
     // FIXME: Dialog can be destroyed while in Execute() check stack variable for dtor flag!
-    if ( !pItem || aDeleted() )
+    if (aDeleted())
+    {
+        // this has been deleted in the previous synchronous slot
+        // call.  Exit without touching anything.
+        return sal_False;
+    }
+    else
+    {
+        // this has not been deleted.  Reset pbDeleted to prevent the
+        // destructor to access the local bool at a later and rather
+        // inconvenient time.  See bugs 124392 and 100110 for more information.
+        pbDeleted = NULL;
+    }
+    if (pItem == NULL)
+    {
         return sal_False;
+    }
 
     if ( nId == SID_STYLE_NEW || SID_STYLE_EDIT == nId )
     {
@@ -1880,10 +1900,6 @@ sal_Bool SfxCommonTemplateDialog_Impl::Execute_Impl(
         }
     }
 
-    // Reset destroyed flag otherwise we use the pointer in the dtor
-    // where the local stack object is already destroyed. This would
-    // overwrite objects on the stack!! See #i100110
-    pbDeleted = NULL;
     return sal_True;
 }
 
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index dcfaef3..90b3cd3 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -243,7 +243,7 @@ public:
 
     SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window*, bool );
     SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window* );
-    ~SfxCommonTemplateDialog_Impl();
+    virtual ~SfxCommonTemplateDialog_Impl();
 
     DECL_LINK( MenuSelectHdl, Menu * );
 
diff --git a/sfx2/source/sidebar/SidebarChildWindow.cxx b/sfx2/source/sidebar/SidebarChildWindow.cxx
index 484a53a..aaf0fa7 100644
--- a/sfx2/source/sidebar/SidebarChildWindow.cxx
+++ b/sfx2/source/sidebar/SidebarChildWindow.cxx
@@ -64,6 +64,13 @@ SidebarChildWindow::SidebarChildWindow (
 
 
 
+SidebarChildWindow::~SidebarChildWindow (void)
+{
+}
+
+
+
+
 sal_Int32 SidebarChildWindow::GetDefaultWidth (Window* pWindow)
 {
     if (pWindow != NULL)
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index b6b56a1..e19e2bd 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -71,6 +71,12 @@ SidebarDockingWindow::~SidebarDockingWindow (void)
 
 void SidebarDockingWindow::DoDispose (void)
 {
+    Reference<lang::XComponent> xComponent (static_cast<XWeak*>(mpSidebarController.get()), UNO_QUERY);
+    mpSidebarController.clear();
+    if (xComponent.is())
+    {
+        xComponent->dispose();
+    }
 }
 
 


More information about the Libreoffice-commits mailing list