vcl/inc/qt5/QtInstanceFormattedSpinButton.hxx |    1 +
 vcl/qt5/QtInstanceBuilder.cxx                 |    1 +
 vcl/qt5/QtInstanceFormattedSpinButton.cxx     |    7 +++++++
 3 files changed, 9 insertions(+)

New commits:
commit 8ff1892730113db075bd0b591c03e083720458ba
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Feb 20 11:12:51 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 20 18:24:34 2025 +0100

    tdf#130857 qt weld: Support Svx(Decimal)NumberDialog
    
    This means that native Qt widgets are used for that dialog
    now when using the qt5 or qt6 VCL plugin and starting LO with
    environment variable SAL_VCL_QT_USE_WELDED_WIDGETS=1 set.
    
    The .ui file is used for 2 dialogs:
    
    * SvxNumberDialog which handles integer values
      and uses "just" weld::SpinButton
    * SvxDecimalNumberDialog which handles decimal numbers
      and uses weld::FormattedSpinButton
    
    Sample steps to trigger the SvxDecimalNumberDialog:
    
    * start Writer
    * "Tools" -> "Options"
    * "LibreOfficeDev" -> "Advanced" -> "Open Expert Configuration"
    * Search for "ColScale" and double-click on the only search result
      (config entry "org.openoffice.Office.Calc" > "Filter" > "Import" >
       "MS_Excel", property "ColScale") to modify it
    
    Handling for decimal numbers using QtInstanceFormattedSpinButton
    still needs some tweaks that will be done in upcoming commits.
    (For example, it currently rounds the value when double-clicking
    on a proparty that has a floating point value set, and only allows
    typing integer values, not actual floating point values.)
    
    Change-Id: I25707ab6c5877eea2270bc21a27d08483d0f52e6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181941
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx
index 595236874b20..727f34e1d645 100644
--- a/vcl/qt5/QtInstanceBuilder.cxx
+++ b/vcl/qt5/QtInstanceBuilder.cxx
@@ -65,6 +65,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& 
rUIFile)
         u"cui/ui/insertrowcolumn.ui"_ustr,
         u"cui/ui/javastartparametersdialog.ui"_ustr,
         u"cui/ui/namedialog.ui"_ustr,
+        u"cui/ui/numberdialog.ui"_ustr,
         u"cui/ui/objecttitledescdialog.ui"_ustr,
         u"cui/ui/optnewdictionarydialog.ui"_ustr,
         u"cui/ui/password.ui"_ustr,
commit 75016899f518109d888c91232c03228ea877c338
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Feb 20 11:24:41 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 20 18:24:27 2025 +0100

    tdf#130857 qt weld: Explicitly reset formatter in spinbutton dtor
    
    This fixes a crash otherwise seen with the upcoming
    
        Change-Id: I25707ab6c5877eea2270bc21a27d08483d0f52e6
        Author: Michael Weghorn <m.wegh...@posteo.de>
    
            tdf#130857 qt weld: Support Svx(Decimal)NumberDialog
    
    which is caused by the weld::EntryFormatter dtor calling
    weld::FormattedSpinButton::SetFormatter (s. frames 8 and 7 below).
    This causes QtInstanceFormattedSpinButton::m_xOwnFormatter
    to be reset while it's already in its own dtor (see dtor in
    both, frames 8/9 and 2/3), triggering a double-free of
    members when returning to the dtor that was called first.
    
    Prevent this the same way as GtkInstanceFormattedSpinButton
    does it by explicitly resetting the `m_xOwnFormatter`
    and `m_xOwnFormatter` members in the QtInstanceFormattedSpinButton
    dtor.
    
    As [1] documents, std::unique_ptr::reset (other than the dtor)
    first assign the new value (here: nullptr) before deleting the
    previously managed object:
    
    > Replaces the managed object.
    > 1,2) Equivalent to
    >
    >       auto old_ptr = get();
    >       /* assigns “ptr” to the stored pointer */
    >       if (old_ptr)
    >           get_deleter()(old_ptr);
    
        1 Formatter::~Formatter fmtfield.cxx 273 0x7f6f181356c4
        2 weld::EntryFormatter::~EntryFormatter weldutils.cxx 159 0x7f6f188b9392
        3 weld::EntryFormatter::~EntryFormatter weldutils.cxx 154 0x7f6f188b93d9
        4 std::default_delete<weld::EntryFormatter>::operator() unique_ptr.h 93 
0x7f6f0dfdecb8
        5 std::__uniq_ptr_impl<weld::EntryFormatter, 
std::default_delete<weld::EntryFormatter>>::reset unique_ptr.h 205 
0x7f6f0dfdf5e8
        6 std::unique_ptr<weld::EntryFormatter, 
std::default_delete<weld::EntryFormatter>>::reset unique_ptr.h 504 
0x7f6f0dfde5bd
        7 QtInstanceFormattedSpinButton::SetFormatter 
QtInstanceFormattedSpinButton.cxx 73 0x7f6f0dfdc7a5
        8 weld::EntryFormatter::~EntryFormatter weldutils.cxx 158 0x7f6f188b9385
        9 weld::EntryFormatter::~EntryFormatter weldutils.cxx 154 0x7f6f188b93d9
        10 std::default_delete<weld::EntryFormatter>::operator() unique_ptr.h 
93 0x7f6f0dfdecb8
        11 std::unique_ptr<weld::EntryFormatter, 
std::default_delete<weld::EntryFormatter>>::~unique_ptr unique_ptr.h 399 
0x7f6f0dfde51f
        12 QtInstanceFormattedSpinButton::~QtInstanceFormattedSpinButton 
QtInstanceFormattedSpinButton.hxx 17 0x7f6f0dfdec2c
        13 QtInstanceFormattedSpinButton::~QtInstanceFormattedSpinButton 
QtInstanceFormattedSpinButton.hxx 17 0x7f6f0dfde6c0
        14 QtInstanceFormattedSpinButton::~QtInstanceFormattedSpinButton 
QtInstanceFormattedSpinButton.hxx 17 0x7f6f0dfde729
        15 std::default_delete<weld::FormattedSpinButton>::operator() 
unique_ptr.h 93 0x7f6edf54bc98
        16 std::unique_ptr<weld::FormattedSpinButton, 
std::default_delete<weld::FormattedSpinButton>>::~unique_ptr unique_ptr.h 399 
0x7f6edf54b16f
        17 SvxDecimalNumberDialog::~SvxDecimalNumberDialog dlgname.hxx 89 
0x7f6edf54b84a
        18 CuiAboutConfigTabPage::StandardHdl_Impl optaboutconfig.cxx 866 
0x7f6edf6ddbd7
        19 CuiAboutConfigTabPage::DoubleClickHdl_Impl optaboutconfig.cxx 773 
0x7f6edf6dd24d
        20 CuiAboutConfigTabPage::LinkStubDoubleClickHdl_Impl 
optaboutconfig.cxx 771 0x7f6edf6d733d
        21 Link<weld::TreeView&, bool>::Call link.hxx 105 0x7f6f18820296
        22 weld::TreeView::signal_row_activated weld.hxx 993 0x7f6f187fce1c
        23 SalInstanceTreeView::DoubleClickHdl salvtables.cxx 5332 
0x7f6f187dc339
        24 SalInstanceTreeView::LinkStubDoubleClickHdl salvtables.cxx 5328 
0x7f6f187d2a6d
        25 Link<SvTreeListBox *, bool>::Call link.hxx 105 0x7f6f17eb0d96
        26 SvTreeListBox::DoubleClickHdl treelistbox.cxx 463 0x7f6f183a1541
    
    [1] https://en.cppreference.com/w/cpp/memory/unique_ptr/reset
    
    Change-Id: Iabdfc6dede2d08406a9605825d41c2acb79f6303
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181940
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/vcl/inc/qt5/QtInstanceFormattedSpinButton.hxx 
b/vcl/inc/qt5/QtInstanceFormattedSpinButton.hxx
index 770ac9fdb4e0..1ae5add3b3ac 100644
--- a/vcl/inc/qt5/QtInstanceFormattedSpinButton.hxx
+++ b/vcl/inc/qt5/QtInstanceFormattedSpinButton.hxx
@@ -25,6 +25,7 @@ class QtInstanceFormattedSpinButton : public QtInstanceEntry,
 
 public:
     QtInstanceFormattedSpinButton(QtDoubleSpinBox* pSpinBox);
+    virtual ~QtInstanceFormattedSpinButton();
 
     virtual QWidget* getQWidget() const override;
 
diff --git a/vcl/qt5/QtInstanceFormattedSpinButton.cxx 
b/vcl/qt5/QtInstanceFormattedSpinButton.cxx
index 418b9e127248..9cc88cab83d3 100644
--- a/vcl/qt5/QtInstanceFormattedSpinButton.cxx
+++ b/vcl/qt5/QtInstanceFormattedSpinButton.cxx
@@ -77,6 +77,12 @@ void 
QtInstanceFormattedSpinButton::SetFormatter(weld::EntryFormatter* pFormatte
     sync_increments_from_formatter();
 }
 
+QtInstanceFormattedSpinButton::~QtInstanceFormattedSpinButton()
+{
+    m_pFormatter = nullptr;
+    m_xOwnFormatter.reset();
+}
+
 void QtInstanceFormattedSpinButton::sync_range_from_formatter()
 {
     SolarMutexGuard g;
commit f1daf188934d079cc2a72266c51085c92438afaa
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Feb 20 10:17:32 2025 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Feb 20 18:24:20 2025 +0100

    tdf#130857 qt weld: Initialize QtInstanceFormattedSpinButton::m_pFormatter
    
    This amends
    
        commit 2bd9ff78c7be6a66a3f4b381bf6726dcce9e2814
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Tue Feb 18 19:07:07 2025 +0100
    
            tdf#130857 qt weld: Introduce QtInstanceFormattedSpinField
    
    Change-Id: Ib4be192d96acefc2603ae3052a3631c46667a55b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181931
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtInstanceFormattedSpinButton.cxx 
b/vcl/qt5/QtInstanceFormattedSpinButton.cxx
index 22b8860dede9..418b9e127248 100644
--- a/vcl/qt5/QtInstanceFormattedSpinButton.cxx
+++ b/vcl/qt5/QtInstanceFormattedSpinButton.cxx
@@ -13,6 +13,7 @@
 QtInstanceFormattedSpinButton::QtInstanceFormattedSpinButton(QtDoubleSpinBox* 
pSpinBox)
     : QtInstanceEntry(pSpinBox->lineEdit())
     , m_pSpinBox(pSpinBox)
+    , m_pFormatter(nullptr)
 {
     assert(pSpinBox);
 

Reply via email to