tdf#130857 weld: Block signals in ComboBox::set_entry_text

As is the case for other weld methods modifying the widget
state, signals about a change of the combobox entry text
are not supposed to be emitted when the change happens
programatically and not by manual user interaction.

Therefore, disable notify events in weld::ComboBox::set_entry_text
by renaming the actual toolkit-specific implementations to
do_set_entry_text and making the weld::ComboBox::set_entry_text
base class method block signals while calling
the virtual methods.

This aligns the behavior of the Qt implementation
with the other ones. For example, the GtkInstanceComboBox
implementation is already blocking the corresponding GTK
signals.

This fixes an issue seen with the qt6 VCL when
support for native Qt widgets is enabled
(SAL_VCL_QT_USE_WELDED_WIDGETS=1)
for the following scenario:

* start Calc
* insert "1" into all of the cells A1:A3
* select A1:A3
* "Data" -> "Pivot Table" -> "Insert or Edit..."
* in the "Select Source" dialog, press OK to confirm "Current Selection"
* in the "Pivot Table Layout" dialog, drag and drop "1" from
  "Available Fields" to "Column Fields"
* press OK
* "Data" -> "Pivot Table" -> "Calculated Field"

(Support for using native Qt widgets will be
enabled in an upcoming commit, now that this issue
is fixed.)

Without this change in place, the "Add" button
would be missing its label, due it being set
to an empty string like this when a dummy entry
is set in the combobox (see frame 50 in the below backtrace):

Backtrace:

    1 QtInstanceButton::set_label QtInstanceButton.cxx 32 0x7fffe4c7350c
    2 ScPivotCalcFieldDlg::CalcFieldNameSelected PivotCalcFieldDialog.cxx 583 0x7fff872b453a
    3 ScPivotCalcFieldDlg::LinkStubCalcFieldNameSelected PivotCalcFieldDialog.cxx 547 0x7fff872b026d
    4 Link<weld::ComboBox&, void>::Call link.hxx 105 0x7fffe4c87f81
    5 weld::ComboBox::signal_changed ComboBox.hxx 71 0x7fffe4c87b98
    6 QtInstanceComboBox::signalChanged QtInstanceComboBox.cxx 431 0x7fffe4c7c05d
    7 QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceComboBox:: *)()>::call(void (QtInstanceComboBox:: *)(), QtInstanceComboBox *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 128 0x7fffe4c883a1
    8 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceComboBox:: *)()>::call(void (QtInstanceComboBox:: *)(), QtInstanceComboBox *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceComboBox:: *)()>::call(void (QtInstanceComboBox:: *)(), QtInstanceComboBox *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 66 0x7fffe4c882d9
    9 QtPrivate::FunctorCall<std::integer_sequence<unsigned long>, QtPrivate::List<>, void, void (QtInstanceComboBox:: *)()>::call(void (QtInstanceComboBox:: *)(), QtInstanceComboBox *, void * *) qobjectdefs_impl.h 127 0x7fffe4c8820b
    10 QtPrivate::FunctionPointer<void (QtInstanceComboBox:: *)()>::call<QtPrivate::List<>, void>(void (QtInstanceComboBox:: *)(), QtInstanceComboBox *, void * *) qobjectdefs_impl.h 175 0x7fffe4c8818d
    11 QtPrivate::QCallableObject<void (QtInstanceComboBox:: *)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase *, QObject *, void * *, bool *) qobjectdefs_impl.h 546 0x7fffe4c880b6
    12 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 462 0x7fffe3aefbf2
    13 doActivate<false> qobject.cpp 4406 0x7fffe3d2691c
    14 QMetaObject::activate qobject.cpp 4467 0x7fffe3d1c8c3
    15 QMetaObject::activate<void, QString> qobjectdefs.h 320 0x7fffe1c8842b
    16 QComboBox::editTextChanged moc_qcombobox.cpp 338 0x7fffe1e46cae
    17 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QComboBox:: *)(QString const&)>::call(void (QComboBox:: *)(QString const&), QComboBox *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 128 0x7fffe1e579f8
    18 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QComboBox:: *)(QString const&)>::call(void (QComboBox:: *)(QString const&), QComboBox *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QComboBox:: *)(QString const&)>::call(void (QComboBox:: *)(QString const&), QComboBox *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 66 0x7fffe1e5796d
    19 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QComboBox:: *)(QString const&)>::call qobjectdefs_impl.h 127 0x7fffe1e57927
    20 QtPrivate::FunctionPointer<void (QComboBox:: *)(QString const&)>::call<QtPrivate::List<QString const&>, void> qobjectdefs_impl.h 175 0x7fffe1e57891
    21 QtPrivate::QCallableObject<void (QComboBox:: *)(QString const&), QtPrivate::List<QString const&>, void>::impl qobjectdefs_impl.h 546 0x7fffe1e577bb
    22 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 462 0x7fffe3aefbf2
    23 doActivate<false> qobject.cpp 4406 0x7fffe3d2691c
    24 QMetaObject::activate qobject.cpp 4467 0x7fffe3d1c8c3
    25 QMetaObject::activate<void, QString> qobjectdefs.h 320 0x7fffe1c8842b
    26 QLineEdit::textChanged moc_qlineedit.cpp 333 0x7fffe1ee36ce
    27 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLineEdit:: *)(QString const&)>::call(void (QLineEdit:: *)(QString const&), QLineEdit *, void * *)::{lambda()#1}::operator()() const qobjectdefs_impl.h 128 0x7fffe1ef1bf8
    28 QtPrivate::FunctorCallBase::call_internal<void, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLineEdit:: *)(QString const&)>::call(void (QLineEdit:: *)(QString const&), QLineEdit *, void * *)::{lambda()#1}>(void * *, QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLineEdit:: *)(QString const&)>::call(void (QLineEdit:: *)(QString const&), QLineEdit *, void * *)::{lambda()#1}&&) qobjectdefs_impl.h 66 0x7fffe1ef1b6d
    29 QtPrivate::FunctorCall<std::integer_sequence<unsigned long, 0ul>, QtPrivate::List<QString const&>, void, void (QLineEdit:: *)(QString const&)>::call qobjectdefs_impl.h 127 0x7fffe1ef1b27
    30 QtPrivate::FunctionPointer<void (QLineEdit:: *)(QString const&)>::call<QtPrivate::List<QString const&>, void> qobjectdefs_impl.h 175 0x7fffe1ef1a91
    31 QtPrivate::QCallableObject<void (QLineEdit:: *)(QString const&), QtPrivate::List<QString const&>, void>::impl qobjectdefs_impl.h 546 0x7fffe1ef19bb
    32 QtPrivate::QSlotObjectBase::call qobjectdefs_impl.h 462 0x7fffe3aefbf2
    33 doActivate<false> qobject.cpp 4406 0x7fffe3d2691c
    34 QMetaObject::activate qobject.cpp 4467 0x7fffe3d1c8c3
    35 QMetaObject::activate<void, QString> qobjectdefs.h 320 0x7fffe1c8842b
    36 QWidgetLineControl::textChanged moc_qwidgetlinecontrol_p.cpp 211 0x7fffe1efa5f1
    37 QWidgetLineControl::finishChange qwidgetlinecontrol.cpp 716 0x7fffe1ef7ce6
    38 QWidgetLineControl::internalSetText qwidgetlinecontrol.cpp 752 0x7fffe1ef944b
    39 QWidgetLineControl::setText qwidgetlinecontrol_p.h 221 0x7fffe1ee64c8
    40 QLineEditPrivate::setText qlineedit_p.cpp 265 0x7fffe1eeba7a
    41 QLineEdit::setText qlineedit.cpp 292 0x7fffe1edbd6e
    42 QComboBox::setEditText qcombobox.cpp 3243 0x7fffe1e47433
    43 QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0::operator()() const QtInstanceComboBox.cxx 233 0x7fffe4c84c66
    44 std::__invoke_impl<void, QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0&>(std::__invoke_other, QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0&) invoke.h 63 0x7fffe4c84c15
    45 std::__invoke_r<void, QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0&>(QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0&) invoke.h 113 0x7fffe4c84bc5
    46 std::_Function_handler<void(), QtInstanceComboBox::set_entry_text(rtl::OUString const&)::$_0>::_M_invoke std_function.h 292 0x7fffe4c84add
    47 std::function<void()>::operator() std_function.h 593 0x7fffe4c3446e
    48 QtInstance::RunInMainThread QtInstance.cxx 216 0x7fffe4c2bbef
    49 QtInstanceComboBox::set_entry_text QtInstanceComboBox.cxx 233 0x7fffe4c7e87a
->  50 ScPivotCalcFieldDlg::AddDummyNewField PivotCalcFieldDialog.cxx 182 0x7fff872b08f7
    51 ScPivotCalcFieldDlg::ScPivotCalcFieldDlg PivotCalcFieldDialog.cxx 81 0x7fff872afca8
    52 std::_Construct<ScPivotCalcFieldDlg, weld::Window *&, ScViewData&, ScDPObject const *&> stl_construct.h 133 0x7fff6ef40f43
    53 std::allocator_traits<std::allocator<void>>::construct<ScPivotCalcFieldDlg, weld::Window *&, ScViewData&, ScDPObject const *&> alloc_traits.h 805 0x7fff6ef40b85
    54 std::_Sp_counted_ptr_inplace<ScPivotCalcFieldDlg, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<weld::Window *&, ScViewData&, ScDPObject const *&> shared_ptr_base.h 606 0x7fff6ef40b85
    55 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<ScPivotCalcFieldDlg, std::allocator<void>, weld::Window *&, ScViewData&, ScDPObject const *&> shared_ptr_base.h 970 0x7fff6ef4090f
    56 std::__shared_ptr<ScPivotCalcFieldDlg, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>, weld::Window *&, ScViewData&, ScDPObject const *&> shared_ptr_base.h 1719 0x7fff6ef4083c
    57 std::shared_ptr<ScPivotCalcFieldDlg>::shared_ptr<std::allocator<void>, weld::Window *&, ScViewData&, ScDPObject const *&> shared_ptr.h 463 0x7fff6ef407ba
    58 std::make_shared<ScPivotCalcFieldDlg, weld::Window *&, ScViewData&, ScDPObject const *&> shared_ptr.h 1007 0x7fff6ef40749
    59 vcl::AbstractDialogImpl_BASE<AbstractScPivotCalcFieldDlg, ScPivotCalcFieldDlg, std::shared_ptr, true>::make_dialog<weld::Window *&, ScViewData&, ScDPObject const *&> abstdlgimpl.hxx 63 0x7fff6ef406c0
    60 AbstractDialogImpl_BASE<weld::Window *&, ScViewData&, ScDPObject const *&> abstdlgimpl.hxx 42 0x7fff6ef40417
    61 AbstractDialogImpl_BASE scdlgfact.cxx 546 0x7fff6ef21995
    62 VclPtr<(anonymous namespace)::AbstractScPivotCalcFieldDlg_Impl>::Create<weld::Window *&, ScViewData&, ScDPObject const *&> vclptr.hxx 153 0x7fff6ef15d98
    63 ScAbstractDialogFactory_Impl::CreateScPivotCalcFieldDlg scdlgfact.cxx 553 0x7fff6ef15cdd
    64 ScPivotShell::Execute pivotsh.cxx 89 0x7fff87aa613b
    65 SfxStubScPivotShellExecute scslots.hxx 5362 0x7fff87aa5fc5
    66 SfxDispatcher::Call_Impl dispatch.cxx 258 0x7ffff37c5b2e
    67 SfxDispatcher::Execute_ dispatch.cxx 757 0x7ffff37ca1f6
    68 SfxBindings::Execute_Impl bindings.cxx 1047 0x7ffff37b20ae
    69 SfxDispatchController_Impl::dispatch unoctitm.cxx 737 0x7ffff388e2bd
    70 SfxOfficeDispatch::dispatch unoctitm.cxx 256 0x7ffff388cd74
    71 framework::(anonymous namespace)::AsyncMenuExecute menubarmanager.cxx 793 0x7ffff4d551a4
    72 Link<void *, void>::Call link.hxx 105 0x7fffedaaaf41
    73 ImplHandleUserEvent winproc.cxx 2314 0x7fffedaa6881
    74 ImplWindowFrameProc winproc.cxx 2869 0x7fffedaa37b5
    75 SalFrame::CallCallback salframe.hxx 309 0x7fffe4c0cc3c
    76 QtInstance::ProcessEvent QtInstance.cxx 564 0x7fffe4c2ea4f
    77 SalUserEventList::DispatchUserEvents(bool)::$_0::operator()() const salusereventlist.cxx 119 0x7fffee07d4ed
    78 SalUserEventList::DispatchUserEvents salusereventlist.cxx 120 0x7fffee07d3c4
    79 QtInstance::ImplYield QtInstance.cxx 458 0x7fffe4c2b3b1
    80 QtInstance::DoYield QtInstance.cxx 480 0x7fffe4c2e611
    81 InnerYield svapp.cxx 389 0x7fffee146746
    82 Application::Yield svapp.cxx 502 0x7fffee145fcf
    83 Application::Execute svapp.cxx 364 0x7fffee145db0
    84 desktop::Desktop::Main app.cxx 1679 0x7ffff7b1f0f5
    85 ImplSVMainRun svmain.cxx 234 0x7fffee16f92c
    86 SalInstance::SVMainRun salinst.hxx 108 0x7fffe4c36b41
    87 ImplSVMain svmain.cxx 221 0x7fffee16ee52
    88 SVMain svmain.cxx 252 0x7fffee1709e9
    89 soffice_main sofficemain.cxx 122 0x7ffff7b9916a
    90 sal_main main.c 51 0x5555555559fd
    91 main main.c 49 0x5555555559d7

Change-Id: Id396e1bcb6e87b8b864257b167f534eb45895d99
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208571
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2026-07-27 20:21:33 +02:00
parent dbe7f551d3
commit 94df4ecce4
8 changed files with 19 additions and 10 deletions
+2 -1
View File
@@ -88,6 +88,7 @@ protected:
= 0;
virtual void do_set_active(int pos) = 0;
virtual void do_set_active_id(const OUString& rStr) = 0;
virtual void do_set_entry_text(const OUString& rStr) = 0;
public:
void insert(int pos, const OUString& rStr, const OUString* pId, const OUString* pIconName,
@@ -167,7 +168,7 @@ public:
//entry related
virtual bool has_entry() const = 0;
virtual void set_entry_message_type(EntryMessageType eType) = 0;
virtual void set_entry_text(const OUString& rStr) = 0;
void set_entry_text(const OUString& rStr);
virtual void set_entry_width_chars(int nChars) = 0;
virtual void set_entry_max_length(int nChars) = 0;
virtual void select_entry_region(int nStartPos, int nEndPos) = 0;
+2 -1
View File
@@ -36,6 +36,8 @@ protected:
m_xTreeView->insert(pos, rStr, pId, pIconName, pImageSurface);
}
virtual void do_set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); }
public:
EntryTreeView(std::unique_ptr<Entry> xEntry, std::unique_ptr<TreeView> xTreeView);
@@ -88,7 +90,6 @@ public:
{
m_xEntry->set_message_type(eType);
}
virtual void set_entry_text(const OUString& rStr) override { m_xEntry->set_text(rStr); }
virtual void set_entry_width_chars(int nChars) override { m_xEntry->set_width_chars(nChars); }
virtual void set_entry_max_length(int nChars) override { m_xEntry->set_max_length(nChars); }
virtual void select_entry_region(int nStartPos, int nEndPos) override
+1 -1
View File
@@ -56,7 +56,7 @@ public:
virtual bool has_entry() const override;
virtual void set_entry_message_type(weld::EntryMessageType eType) override;
virtual void set_entry_text(const OUString& rStr) override;
virtual void do_set_entry_text(const OUString& rStr) override;
virtual void set_entry_width_chars(int nChars) override;
virtual void set_entry_max_length(int nChars) override;
virtual void select_entry_region(int nStartPos, int nEndPos) override;
+2 -2
View File
@@ -966,7 +966,7 @@ public:
virtual void set_entry_message_type(weld::EntryMessageType /*eType*/) override;
virtual void set_entry_text(const OUString& /*rText*/) override;
virtual void do_set_entry_text(const OUString& /*rText*/) override;
virtual void select_entry_region(int /*nStartPos*/, int /*nEndPos*/) override;
@@ -1039,7 +1039,7 @@ public:
virtual void insert_separator(int pos, const OUString& /*rId*/) override;
virtual void set_entry_text(const OUString& rText) override;
virtual void do_set_entry_text(const OUString& rText) override;
virtual void set_entry_width_chars(int nChars) override;
+1 -1
View File
@@ -227,7 +227,7 @@ void QtInstanceComboBox::set_entry_message_type(weld::EntryMessageType eType)
QtInstanceEntry::setMessageType(*m_pComboBox->lineEdit(), eType);
}
void QtInstanceComboBox::set_entry_text(const OUString& rStr)
void QtInstanceComboBox::do_set_entry_text(const OUString& rStr)
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pComboBox->setEditText(toQString(rStr)); });
+2 -2
View File
@@ -5852,7 +5852,7 @@ void SalInstanceComboBoxWithoutEdit::set_entry_message_type(weld::EntryMessageTy
assert(false);
}
void SalInstanceComboBoxWithoutEdit::set_entry_text(const OUString& /*rText*/) { assert(false); }
void SalInstanceComboBoxWithoutEdit::do_set_entry_text(const OUString& /*rText*/) { assert(false); }
void SalInstanceComboBoxWithoutEdit::select_entry_region(int /*nStartPos*/, int /*nEndPos*/)
{
@@ -5999,7 +5999,7 @@ void SalInstanceComboBoxWithEdit::insert_separator(int pos, const OUString& /*rI
m_xComboBox->AddSeparator(nInsertPos - 1);
}
void SalInstanceComboBoxWithEdit::set_entry_text(const OUString& rText)
void SalInstanceComboBoxWithEdit::do_set_entry_text(const OUString& rText)
{
m_xComboBox->SetText(rText);
}
+7
View File
@@ -33,6 +33,13 @@ void weld::ComboBox::set_active_id(const OUString& rStr)
enable_notify_events();
}
void weld::ComboBox::set_entry_text(const OUString& rStr)
{
disable_notify_events();
do_set_entry_text(rStr);
enable_notify_events();
}
bool weld::ComboBox::get_values_changed_from_saved() const
{
return !m_aSavedValues.empty()
+2 -2
View File
@@ -20084,7 +20084,7 @@ public:
::set_entry_message_type(GTK_ENTRY(m_pEntry), eType);
}
virtual void set_entry_text(const OUString& rText) override
virtual void do_set_entry_text(const OUString& rText) override
{
assert(m_pEditable);
disable_notify_events();
@@ -22036,7 +22036,7 @@ public:
::set_entry_message_type(GTK_ENTRY(m_pEntry), eType);
}
virtual void set_entry_text(const OUString& rText) override
virtual void do_set_entry_text(const OUString& rText) override
{
assert(m_pEntry);
disable_notify_events();