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 <m.weghorn@posteo.de>
    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 <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2025-04-11 22:14:54 +02:00
parent bb7cbdb74f
commit b03bf3bbb1
2 changed files with 7 additions and 16 deletions

View File

@ -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;

View File

@ -606,10 +606,14 @@ void AssignmentPersistentData::ImplCommit()
for (sal_Int32 i = 0; i<nAdjustedTokenCount; ++i)
m_pImpl->aLogicalFieldNames.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())