[Libreoffice-commits] core.git: include/svx include/vcl svtools/source svx/source vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Sun Dec 20 16:37:33 UTC 2020


 include/svx/gridctrl.hxx          |    4 ++--
 include/vcl/weldutils.hxx         |    1 +
 svtools/source/control/tabbar.cxx |   18 +++++++++---------
 svx/source/fmcomp/gridctrl.cxx    |    8 ++++----
 vcl/source/app/weldutils.cxx      |    3 +++
 5 files changed, 19 insertions(+), 15 deletions(-)

New commits:
commit a0bf3da7a610e35862878687fed01b63ee5e5308
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sat Dec 19 22:22:18 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sun Dec 20 17:36:53 2020 +0100

    tdf#139063 crash when add a new sheet to a RTL sheet
    
    Change-Id: Icbfb45036f93ed92e5c83039cd4c3b536f0df0d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108036
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/gridctrl.hxx b/include/svx/gridctrl.hxx
index e09b0a146284..7667d456bd00 100644
--- a/include/svx/gridctrl.hxx
+++ b/include/svx/gridctrl.hxx
@@ -190,8 +190,8 @@ class NavigationBar final : public InterimItemWindow
     std::unique_ptr<weld::Button> m_xLastBtn;         // Button for 'go to the last record'
     std::unique_ptr<weld::Button> m_xNewBtn;          // Button for 'go to a new record'
 
-    weld::ButtonPressRepeater m_aPrevRepeater;
-    weld::ButtonPressRepeater m_aNextRepeater;
+    std::shared_ptr<weld::ButtonPressRepeater> m_xPrevRepeater;
+    std::shared_ptr<weld::ButtonPressRepeater> m_xNextRepeater;
 
     sal_Int32            m_nCurrentPos;
 
diff --git a/include/vcl/weldutils.hxx b/include/vcl/weldutils.hxx
index 43461ab6fb51..86af6c6e95ee 100644
--- a/include/vcl/weldutils.hxx
+++ b/include/vcl/weldutils.hxx
@@ -397,6 +397,7 @@ private:
 };
 
 class VCL_DLLPUBLIC ButtonPressRepeater final
+    : public std::enable_shared_from_this<ButtonPressRepeater>
 {
 private:
     weld::Button& m_rButton;
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx
index 1beda5faeff6..640d767477d6 100644
--- a/svtools/source/control/tabbar.cxx
+++ b/svtools/source/control/tabbar.cxx
@@ -426,9 +426,9 @@ public:
     std::unique_ptr<weld::Button> m_xNextButton;
     std::unique_ptr<weld::Button> m_xLastButton;
     std::unique_ptr<weld::Button> m_xAddButton;
-    std::unique_ptr<weld::ButtonPressRepeater> m_xAddRepeater;
-    std::unique_ptr<weld::ButtonPressRepeater> m_xPrevRepeater;
-    std::unique_ptr<weld::ButtonPressRepeater> m_xNextRepeater;
+    std::shared_ptr<weld::ButtonPressRepeater> m_xAddRepeater;
+    std::shared_ptr<weld::ButtonPressRepeater> m_xPrevRepeater;
+    std::shared_ptr<weld::ButtonPressRepeater> m_xNextRepeater;
 
     TabButtons(TabBar* pParent)
         : InterimItemWindow(pParent,
@@ -780,8 +780,8 @@ void TabBar::ImplInitControls()
     if (mnWinStyle & WB_INSERTTAB)
     {
         Link<weld::Button&,void> aLink = LINK(this, TabBar, ImplAddClickHandler);
-        mpImpl->mxButtonBox->m_xAddRepeater.reset(new weld::ButtonPressRepeater(
-                    *mpImpl->mxButtonBox->m_xAddButton, aLink, aContextLink));
+        mpImpl->mxButtonBox->m_xAddRepeater = std::make_shared<weld::ButtonPressRepeater>(
+                    *mpImpl->mxButtonBox->m_xAddButton, aLink, aContextLink);
         mpImpl->mxButtonBox->m_xAddButton->show();
     }
 
@@ -789,11 +789,11 @@ void TabBar::ImplInitControls()
 
     if (mnWinStyle & (WB_MINSCROLL | WB_SCROLL))
     {
-        mpImpl->mxButtonBox->m_xPrevRepeater.reset(new weld::ButtonPressRepeater(
-                    *mpImpl->mxButtonBox->m_xPrevButton, aLink, aContextLink));
+        mpImpl->mxButtonBox->m_xPrevRepeater = std::make_shared<weld::ButtonPressRepeater>(
+                    *mpImpl->mxButtonBox->m_xPrevButton, aLink, aContextLink);
         mpImpl->mxButtonBox->m_xPrevButton->show();
-        mpImpl->mxButtonBox->m_xNextRepeater.reset(new weld::ButtonPressRepeater(
-                    *mpImpl->mxButtonBox->m_xNextButton, aLink, aContextLink));
+        mpImpl->mxButtonBox->m_xNextRepeater = std::make_shared<weld::ButtonPressRepeater>(
+                    *mpImpl->mxButtonBox->m_xNextButton, aLink, aContextLink);
         mpImpl->mxButtonBox->m_xNextButton->show();
     }
 
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index b004aed7d7d9..41f3255e3585 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -317,8 +317,8 @@ NavigationBar::NavigationBar(vcl::Window* pParent)
     , m_xNextBtn(m_xBuilder->weld_button("next"))
     , m_xLastBtn(m_xBuilder->weld_button("last"))
     , m_xNewBtn(m_xBuilder->weld_button("new"))
-    , m_aPrevRepeater(*m_xPrevBtn, LINK(this,NavigationBar,OnClick))
-    , m_aNextRepeater(*m_xNextBtn, LINK(this,NavigationBar,OnClick))
+    , m_xPrevRepeater(std::make_shared<weld::ButtonPressRepeater>(*m_xPrevBtn, LINK(this,NavigationBar,OnClick)))
+    , m_xNextRepeater(std::make_shared<weld::ButtonPressRepeater>(*m_xNextBtn, LINK(this,NavigationBar,OnClick)))
     , m_nCurrentPos(-1)
     , m_bPositioning(false)
 {
@@ -577,9 +577,9 @@ void NavigationBar::SetState(DbGridControlNavigationBarState nWhich)
     if (!bAvailable)
     {
         if (pWnd == m_xNextBtn.get())
-            m_aNextRepeater.Stop();
+            m_xNextRepeater->Stop();
         else if (pWnd == m_xPrevBtn.get())
-            m_aPrevRepeater.Stop();
+            m_xPrevRepeater->Stop();
     }
 }
 
diff --git a/vcl/source/app/weldutils.cxx b/vcl/source/app/weldutils.cxx
index bce1f478a1f1..836f6220e222 100644
--- a/vcl/source/app/weldutils.cxx
+++ b/vcl/source/app/weldutils.cxx
@@ -576,7 +576,10 @@ IMPL_LINK(ButtonPressRepeater, MousePressHdl, const MouseEvent&, rMouseEvent, bo
     m_bModKey = rMouseEvent.IsMod1();
     if (!m_rButton.get_sensitive())
         return false;
+    auto self = weak_from_this();
     RepeatTimerHdl(nullptr);
+    if (!self.lock())
+        return false;
     if (!m_rButton.get_sensitive())
         return false;
     m_aRepeat.SetTimeout(MouseSettings::GetButtonStartRepeat());


More information about the Libreoffice-commits mailing list