This is an automated email from the ASF dual-hosted git repository.
ardovm pushed a commit to branch AOO41X
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/AOO41X by this push:
new a2db8daa58 Search for updates in the main thread. (#427)
a2db8daa58 is described below
commit a2db8daa583f26f37049ecee9be51ff7090a8b59
Author: Arrigo Marchiori <[email protected]>
AuthorDate: Wed Oct 1 21:13:33 2025 +0200
Search for updates in the main thread. (#427)
Bypass and remove class InitUpdateCheckJobThread.
Updates are not checked automatically any more.
Also, lock the Solar Mutex whenever accessing the GUI.
(cherry picked and adapted from commit
b838f7250280accb8f6cdc9cbe4a034b657b83c5)
---
main/extensions/prj/build.lst | 2 +-
main/extensions/source/update/check/Jobs.xcu | 5 --
main/extensions/source/update/check/makefile.mk | 5 +-
.../source/update/check/updatecheckjob.cxx | 84 ++--------------------
main/extensions/source/update/check/updatehdl.cxx | 17 +++++
5 files changed, 26 insertions(+), 87 deletions(-)
diff --git a/main/extensions/prj/build.lst b/main/extensions/prj/build.lst
index 8a815ee31c..0616a5ca38 100644
--- a/main/extensions/prj/build.lst
+++ b/main/extensions/prj/build.lst
@@ -1,4 +1,4 @@
-ex extensions : officecfg L10N:l10n rdbmaker svx SANE:sane TWAIN:twain
offuh stoc ZLIB:zlib CURL:curl LIBXSLT:libxslt NULL
+ex extensions : officecfg L10N:l10n rdbmaker svx SANE:sane TWAIN:twain
offuh stoc vcl ZLIB:zlib CURL:curl LIBXSLT:libxslt NULL
ex extensions usr1 - all ex_mkout NULL
ex extensions\inc nmake - all ex_inc NULL
diff --git a/main/extensions/source/update/check/Jobs.xcu
b/main/extensions/source/update/check/Jobs.xcu
index 31e48394cf..267f5832de 100644
--- a/main/extensions/source/update/check/Jobs.xcu
+++ b/main/extensions/source/update/check/Jobs.xcu
@@ -57,11 +57,6 @@
</node>
</node>
<node oor:name="Events">
- <node oor:name="onFirstVisibleTask" oor:op="fuse">
- <node oor:name="JobList">
- <node oor:name="UpdateCheck" oor:op="replace"/>
- </node>
- </node>
</node>
</oor:component-data>
diff --git a/main/extensions/source/update/check/makefile.mk
b/main/extensions/source/update/check/makefile.mk
index ab88e85402..963428101d 100644
--- a/main/extensions/source/update/check/makefile.mk
+++ b/main/extensions/source/update/check/makefile.mk
@@ -86,8 +86,9 @@ SHL1STDLIBS= \
$(CURLLIB) \
$(SALLIB) \
$(SHELL32LIB) \
- $(OLE32LIB)
-
+ $(OLE32LIB) \
+ $(VCLLIB)
+
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
diff --git a/main/extensions/source/update/check/updatecheckjob.cxx
b/main/extensions/source/update/check/updatecheckjob.cxx
index 600fab4da1..799f2f4454 100644
--- a/main/extensions/source/update/check/updatecheckjob.cxx
+++ b/main/extensions/source/update/check/updatecheckjob.cxx
@@ -49,26 +49,7 @@ namespace uno = com::sun::star::uno ;
namespace
{
-class InitUpdateCheckJobThread : public osl::Thread
-{
-public:
- InitUpdateCheckJobThread( const uno::Reference< uno::XComponentContext >
&xContext,
- const uno::Sequence< beans::NamedValue >
&xParameters,
- bool bShowDialog );
-
- virtual void SAL_CALL run();
-
- void setTerminating();
-
-private:
- osl::Condition m_aCondition;
- uno::Reference<uno::XComponentContext> m_xContext;
- uno::Sequence<beans::NamedValue> m_xParameters;
- bool m_bShowDialog;
- bool m_bTerminating;
-};
-
-class UpdateCheckJob :
+class UpdateCheckJob :
public ::cppu::WeakImplHelper3< task::XJob, lang::XServiceInfo,
frame::XTerminateListener >
{
virtual ~UpdateCheckJob();
@@ -109,50 +90,10 @@ public:
private:
uno::Reference<uno::XComponentContext> m_xContext;
uno::Reference< frame::XDesktop > m_xDesktop;
- std::auto_ptr< InitUpdateCheckJobThread > m_pInitThread;
void handleExtensionUpdates( const uno::Sequence< beans::NamedValue >
&rListProp );
};
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-InitUpdateCheckJobThread::InitUpdateCheckJobThread(
- const uno::Reference< uno::XComponentContext > &xContext,
- const uno::Sequence< beans::NamedValue > &xParameters,
- bool bShowDialog ) :
- m_xContext( xContext ),
- m_xParameters( xParameters ),
- m_bShowDialog( bShowDialog ),
- m_bTerminating( false )
-{
- create();
-}
-
-//------------------------------------------------------------------------------
-void SAL_CALL InitUpdateCheckJobThread::run()
-{
- if (!m_bShowDialog) {
- TimeValue tv = { 25, 0 };
- m_aCondition.wait( &tv );
- if ( m_bTerminating )
- return;
- }
-
- rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
- aController->initialize( m_xParameters, m_xContext );
-
- if ( m_bShowDialog )
- aController->showDialog( true );
-}
-
-void InitUpdateCheckJobThread::setTerminating() {
- m_bTerminating = true;
- m_aCondition.set();
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
UpdateCheckJob::UpdateCheckJob( const uno::Reference<uno::XComponentContext>&
xContext ) :
@@ -216,20 +157,10 @@ UpdateCheckJob::execute(const
uno::Sequence<beans::NamedValue>& namedValues)
uno::Sequence<beans::NamedValue> aConfig =
getValue< uno::Sequence<beans::NamedValue> > (namedValues,
"JobConfig");
- /* Determine the way we got invoked here -
- * see Developers Guide Chapter "4.7.2 Jobs" to understand the magic
- */
-
- uno::Sequence<beans::NamedValue> aEnvironment =
- getValue< uno::Sequence<beans::NamedValue> > (namedValues,
"Environment");
-
- rtl::OUString aEventName = getValue< rtl::OUString > (aEnvironment,
"EventName");
-
- m_pInitThread.reset(
- new InitUpdateCheckJobThread(
- m_xContext, aConfig,
- !aEventName.equalsAscii("onFirstVisibleTask")));
-
+ rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
+ aController->initialize( aConfig, m_xContext );
+ aController->showDialog( true );
+
return uno::Any();
}
@@ -326,11 +257,6 @@ void SAL_CALL UpdateCheckJob::queryTermination(
lang::EventObject const & )
void SAL_CALL UpdateCheckJob::notifyTermination( lang::EventObject const & )
throw ( uno::RuntimeException )
{
- if ( m_pInitThread.get() != 0 )
- {
- m_pInitThread->setTerminating();
- m_pInitThread->join();
- }
}
} // anonymous namespace
diff --git a/main/extensions/source/update/check/updatehdl.cxx
b/main/extensions/source/update/check/updatehdl.cxx
index bb2f2b5e8c..ecf931edf2 100644
--- a/main/extensions/source/update/check/updatehdl.cxx
+++ b/main/extensions/source/update/check/updatehdl.cxx
@@ -67,6 +67,9 @@
#include "updatehdl.hrc"
#include <tools/urlobj.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.hxx>
+
#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
#define COMMAND_CLOSE UNISTRING("close")
@@ -177,6 +180,7 @@ bool UpdateHandler::isVisible() const
{
if ( !mxUpdDlg.is() ) return false;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XWindow2 > xWindow( mxUpdDlg, uno::UNO_QUERY );
if ( xWindow.is() )
@@ -203,6 +207,7 @@ void UpdateHandler::setVisible( bool bVisible )
updateState( meCurState );
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
if ( xWindow.is() )
@@ -221,6 +226,7 @@ void UpdateHandler::setVisible( bool bVisible )
}
else if ( mxUpdDlg.is() )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
if ( xWindow.is() )
@@ -390,6 +396,7 @@ void SAL_CALL UpdateHandler::windowOpened( const
lang::EventObject& )
void SAL_CALL UpdateHandler::windowClosing( const lang::EventObject& e )
throw( uno::RuntimeException )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
awt::ActionEvent aActionEvt;
aActionEvt.ActionCommand = COMMAND_CLOSE;
aActionEvt.Source = e.Source;
@@ -484,6 +491,7 @@ void SAL_CALL UpdateHandler::queryTermination( const
lang::EventObject& )
{
if ( mbShowsMessageBox )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY
);
if ( xTopWindow.is() )
xTopWindow->toFront();
@@ -504,6 +512,7 @@ void SAL_CALL UpdateHandler::notifyTermination( const
lang::EventObject& )
if ( mxUpdDlg.is() )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY
);
if ( xTopWindow.is() )
xTopWindow->removeTopWindowListener( this );
@@ -754,6 +763,7 @@ void UpdateHandler::loadStrings()
//--------------------------------------------------------------------
void UpdateHandler::startThrobber( bool bStart )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg,
uno::UNO_QUERY );
uno::Reference< awt::XAnimation > xThrobber( xContainer->getControl(
CTRL_THROBBER ), uno::UNO_QUERY );
@@ -777,6 +787,7 @@ void UpdateHandler::setControlProperty( const rtl::OUString
&rCtrlName,
{
if ( !mxUpdDlg.is() ) return;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg,
uno::UNO_QUERY );
uno::Reference< awt::XControl > xControl( xContainer->getControl(
rCtrlName ), uno::UNO_QUERY_THROW );
uno::Reference< awt::XControlModel > xControlModel( xControl->getModel(),
uno::UNO_QUERY_THROW );
@@ -794,6 +805,7 @@ void UpdateHandler::setControlProperty( const rtl::OUString
&rCtrlName,
//--------------------------------------------------------------------
void UpdateHandler::showControl( const rtl::OUString &rCtrlName, bool bShow )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg,
uno::UNO_QUERY );
if ( !xContainer.is() )
@@ -810,6 +822,7 @@ void UpdateHandler::showControl( const rtl::OUString
&rCtrlName, bool bShow )
//--------------------------------------------------------------------
void UpdateHandler::focusControl( DialogControls eID )
{
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg,
uno::UNO_QUERY );
if ( !xContainer.is() )
@@ -826,6 +839,7 @@ void UpdateHandler::focusControl( DialogControls eID )
}
//--------------------------------------------------------------------
+// Requires the Solar Mutex to be locked
void UpdateHandler::insertControlModel( uno::Reference< awt::XControlModel > &
rxDialogModel,
rtl::OUString const & rServiceName,
rtl::OUString const & rControlName,
@@ -936,6 +950,7 @@ bool UpdateHandler::showWarning( const rtl::OUString
&rWarningText ) const
{
bool bRet = false;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
if ( !xControl.is() ) return bRet;
@@ -985,6 +1000,7 @@ bool UpdateHandler::showWarning( const rtl::OUString
&rWarningText,
{
bool bRet = false;
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
if ( !xControl.is() ) return bRet;
@@ -1153,6 +1169,7 @@ void UpdateHandler::createDialog()
loadStrings();
+ ::vos::OGuard aGuard( Application::GetSolarMutex() );
uno::Reference< lang::XMultiComponentFactory > xFactory(
mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference< awt::XControlModel > xControlModel(
xFactory->createInstanceWithContext(
UNISTRING("com.sun.star.awt.UnoControlDialogModel"),