From b03bf3bbb1457671110f1cd9c503eacdb6441da5 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 11 Apr 2025 22:14:54 +0200 Subject: [PATCH] tdf#130857 address book source dialog: No more do delayed initialization Posting a user event and initialize things when that event gets processed doesn't work with the qt6 VCL plugin when using native widgets (for which support will be added in an upcoming commit). There, the user event only gets processed after the dialog gets closed, and then results in a crash when support for the dialog is declared in QtInstanceBuilder::IsUIFileSupported. This seems similar to the scenario in commit 29d6065d9a687f1d86f26f53587e108f8c951a4a Author: Michael Weghorn Date: Mon Sep 16 15:21:01 2024 +0200 sfx2: Synchronously set control state in file picker on all platforms As was done there, do the work right away instead. Should that result in any unresponsiveness for certain scenarios, those will have to be examined more closely. (At least with the Bibliography database used for the data source, all seems fine.) Change-Id: Ic2d35df49b683c27c2b505018374f421699f6711 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184079 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- include/svtools/addresstemplate.hxx | 1 - svtools/source/dialogs/addresstemplate.cxx | 22 +++++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/include/svtools/addresstemplate.hxx b/include/svtools/addresstemplate.hxx index 04ce8d9be68d..d7f1b6517b2f 100644 --- a/include/svtools/addresstemplate.hxx +++ b/include/svtools/addresstemplate.hxx @@ -99,7 +99,6 @@ namespace svt DECL_DLLPRIVATE_LINK(OnComboLoseFocus, weld::Widget&, void); DECL_DLLPRIVATE_LINK(OnComboSelect, weld::ComboBox&, void); DECL_DLLPRIVATE_LINK(OnOkClicked, weld::Button&, void); - DECL_DLLPRIVATE_LINK(OnDelayedInitialize, void*, void); // string to display for "no selection" const OUString m_sNoFieldSelection; diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx index 150e79ac85c9..8877108e899d 100644 --- a/svtools/source/dialogs/addresstemplate.cxx +++ b/svtools/source/dialogs/addresstemplate.cxx @@ -606,10 +606,14 @@ void AssignmentPersistentData::ImplCommit() for (sal_Int32 i = 0; iaLogicalFieldNames.push_back(sLogicalFieldNames.getToken(0, ';', nIdx)); - Application::PostUserEvent(LINK(this, AddressBookSourceDialog, OnDelayedInitialize), nullptr, false); + // load the initial data from the configuration + loadConfiguration(); + resetTables(); + // will reset the tables/fields implicitly - // so the dialog will at least show up before we do the loading of the - // configuration data and the (maybe time consuming) analysis of the data source/table to select + if ( !m_pImpl->bWorkingPersistent ) + if ( m_pImpl->pFields[0] ) + m_pImpl->pFields[0]->grab_focus(); if (m_pImpl->bWorkingPersistent) return; @@ -998,18 +1002,6 @@ void AssignmentPersistentData::ImplCommit() pBox->set_active(0); } - IMPL_LINK_NOARG(AddressBookSourceDialog, OnDelayedInitialize, void*, void) - { - // load the initial data from the configuration - loadConfiguration(); - resetTables(); - // will reset the tables/fields implicitly - - if ( !m_pImpl->bWorkingPersistent ) - if ( m_pImpl->pFields[0] ) - m_pImpl->pFields[0]->grab_focus(); - } - IMPL_LINK(AddressBookSourceDialog, OnComboSelect, weld::ComboBox&, rBox, void) { if (&rBox == m_xDatasource.get())