[Libreoffice-commits] core.git: dbaccess/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 21 12:17:51 UTC 2018


 dbaccess/source/ui/control/dbtreelistbox.cxx |   24 +++++++++++++++---------
 dbaccess/source/ui/inc/dbtreelistbox.hxx     |    3 ++-
 2 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit b2e7e5ac8d511ada9e254d86b2f16509d4b9b977
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Dec 20 21:29:27 2018 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Dec 21 13:17:24 2018 +0100

    tdf#122020 crash in SvTreeList::InvalidateEntry
    
    a PostUserEvent of DBTreeListBox::OnResetEntry with a SvTreeListEntry* pEntry as
    payload, then the DBTreeListBox is disposed and then the UserEvent arrives and
    the, by now deleted, pEntry is processed by the disposed DBTreeListBox
    
    Change-Id: I951639eb633920aa3536cd44320f36f6b2e910aa
    Reviewed-on: https://gerrit.libreoffice.org/65512
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/dbaccess/source/ui/control/dbtreelistbox.cxx b/dbaccess/source/ui/control/dbtreelistbox.cxx
index 03b87a1b2517..2edbd0f6195a 100644
--- a/dbaccess/source/ui/control/dbtreelistbox.cxx
+++ b/dbaccess/source/ui/control/dbtreelistbox.cxx
@@ -59,7 +59,8 @@ DBTreeListBox::DBTreeListBox( vcl::Window* pParent, WinBits nWinStyle )
     :SvTreeListBox(pParent,nWinStyle)
     ,m_pDragedEntry(nullptr)
     ,m_pActionListener(nullptr)
-    ,m_pContextMenuProvider( nullptr )
+    ,m_pContextMenuProvider(nullptr)
+    ,m_pResetEvent(nullptr)
 {
     init();
 }
@@ -89,6 +90,11 @@ DBTreeListBox::~DBTreeListBox()
 
 void DBTreeListBox::dispose()
 {
+    if (m_pResetEvent)
+    {
+        RemoveUserEvent(m_pResetEvent);
+        m_pResetEvent = nullptr;
+    }
     implStopSelectionTimer();
     SvTreeListBox::dispose();
 }
@@ -119,11 +125,6 @@ SvTreeListEntry* DBTreeListBox::GetEntryPosByName( const OUString& aName, SvTree
     return pEntry;
 }
 
-void DBTreeListBox::EnableExpandHandler(SvTreeListEntry* _pEntry)
-{
-    LINK(this, DBTreeListBox, OnResetEntry).Call(_pEntry);
-}
-
 void DBTreeListBox::RequestingChildren( SvTreeListEntry* pParent )
 {
     if (m_aPreExpandHandler.IsSet() && !m_aPreExpandHandler.Call(pParent))
@@ -131,7 +132,7 @@ void DBTreeListBox::RequestingChildren( SvTreeListEntry* pParent )
         // an error occurred. The method calling us will reset the entry flags, so it can't be expanded again.
         // But we want that the user may do a second try (i.e. because he mistypes a password in this try), so
         // we have to reset these flags controlling the expand ability
-        PostUserEvent(LINK(this, DBTreeListBox, OnResetEntry), pParent, true);
+        m_pResetEvent = PostUserEvent(LINK(this, DBTreeListBox, OnResetEntryHdl), pParent, true);
     }
 }
 
@@ -177,9 +178,8 @@ void DBTreeListBox::MouseButtonDown( const MouseEvent& rMEvt )
         SvTreeListBox::MouseButtonDown(rMEvt);
 }
 
-IMPL_LINK(DBTreeListBox, OnResetEntry, void*, p, void)
+void DBTreeListBox::EnableExpandHandler(SvTreeListEntry* pEntry)
 {
-    SvTreeListEntry* pEntry = static_cast<SvTreeListEntry*>(p);
     // set the flag which allows if the entry can be expanded
     pEntry->SetFlags( (pEntry->GetFlags() & ~SvTLEntryFlags(SvTLEntryFlags::NO_NODEBMP | SvTLEntryFlags::HAD_CHILDREN)) | SvTLEntryFlags::CHILDREN_ON_DEMAND );
     // redraw the entry
@@ -188,6 +188,12 @@ IMPL_LINK(DBTreeListBox, OnResetEntry, void*, p, void)
         myModel->InvalidateEntry( pEntry );
 }
 
+IMPL_LINK(DBTreeListBox, OnResetEntryHdl, void*, p, void)
+{
+    m_pResetEvent = nullptr;
+    EnableExpandHandler(static_cast<SvTreeListEntry*>(p));
+}
+
 void DBTreeListBox::ModelHasEntryInvalidated( SvTreeListEntry* _pEntry )
 {
     SvTreeListBox::ModelHasEntryInvalidated( _pEntry );
diff --git a/dbaccess/source/ui/inc/dbtreelistbox.hxx b/dbaccess/source/ui/inc/dbtreelistbox.hxx
index d267ceb129bd..7e3beb87d480 100644
--- a/dbaccess/source/ui/inc/dbtreelistbox.hxx
+++ b/dbaccess/source/ui/inc/dbtreelistbox.hxx
@@ -57,6 +57,7 @@ namespace dbaui
         SvTreeListEntry*            m_pDragedEntry;
         IControlActionListener*     m_pActionListener;
         IContextMenuProvider*       m_pContextMenuProvider;
+        ImplSVEvent*                m_pResetEvent;
         css::uno::Reference<css::frame::XPopupMenuController> m_xMenuController;
 
         Link<SvTreeListEntry*,bool> m_aPreExpandHandler;    // handler to be called before a node is expanded
@@ -69,7 +70,7 @@ namespace dbaui
     private:
         void init();
         DECL_LINK( OnTimeOut, Timer*, void );
-        DECL_LINK( OnResetEntry, void*, void );
+        DECL_LINK( OnResetEntryHdl, void*, void );
         DECL_LINK( ScrollUpHdl, LinkParamNone*, void );
         DECL_LINK( ScrollDownHdl, LinkParamNone*, void );
         DECL_LINK( MenuEventListener, VclMenuEvent&, void );


More information about the Libreoffice-commits mailing list