[Libreoffice-commits] core.git: basctl/source basic/source fpicker/source framework/source include/vcl sc/source sfx2/source svx/source sw/source vbahelper/source vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Mar 14 07:21:37 UTC 2021


 basctl/source/basicide/baside2.cxx        |    2 +-
 basic/source/classes/sbxmod.cxx           |    2 +-
 basic/source/runtime/methods1.cxx         |    2 +-
 fpicker/source/win32/asyncrequests.cxx    |    2 +-
 framework/source/loadenv/loadenv.cxx      |    2 +-
 include/vcl/svapp.hxx                     |    4 ++++
 sc/source/filter/oox/workbookfragment.cxx |    2 +-
 sfx2/source/doc/docfile.cxx               |    2 +-
 sfx2/source/doc/printhelper.cxx           |    4 ++--
 svx/source/dialog/docrecovery.cxx         |    2 +-
 sw/source/uibase/dbui/dbmgr.cxx           |    2 +-
 vbahelper/source/vbahelper/vbahelper.cxx  |    2 +-
 vcl/source/app/svapp.cxx                  |    5 +++++
 vcl/source/control/prgsbar.cxx            |    2 +-
 vcl/source/window/dialog.cxx              |    2 +-
 vcl/source/window/menufloatingwindow.cxx  |    2 +-
 vcl/source/window/syswin.cxx              |    2 +-
 17 files changed, 25 insertions(+), 16 deletions(-)

New commits:
commit c880d3e30405342a5ae6239cc77f69ed3ca6cc15
Author:     Noel Grandin <noelgrandin at gmail.com>
AuthorDate: Sat Mar 13 09:36:46 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Mar 14 08:20:53 2021 +0100

    check for quit when calling Yield in loop
    
    so we don't get stuck threads when the main application
    quits
    
    Change-Id: Id36e99267ceb4154873b6ef8ef494622fff6c19a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112409
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 7c8d1ff01610..6cabab5df38d 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -680,7 +680,7 @@ BasicDebugFlags ModulWindow::BasicBreakHdl()
 
     InvalidateDebuggerSlots();
 
-    while( m_aStatus.bIsRunning )
+    while( m_aStatus.bIsRunning && !Application::IsQuit())
         Application::Yield();
 
     m_aStatus.bIsInReschedule = false;
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index cacaa7650357..a69a3f508ec7 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1048,7 +1048,7 @@ namespace
             if (m_bDelInst)
             {
                 // Compare here with 1 instead of 0, because before nCallLvl--
-                while (m_pSbData->pInst->nCallLvl != 1)
+                while (m_pSbData->pInst->nCallLvl != 1 && !Application::IsQuit())
                     Application::Yield();
             }
 
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 3fc1b0c2bf3a..2f89a90a8149 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -581,7 +581,7 @@ void Wait_Impl( bool bDurationBased, SbxArray& rPar )
     Timer aTimer;
     aTimer.SetTimeout( nWait );
     aTimer.Start();
-    while ( aTimer.IsActive() )
+    while ( aTimer.IsActive() && !Application::IsQuit())
     {
         Application::Yield();
     }
diff --git a/fpicker/source/win32/asyncrequests.cxx b/fpicker/source/win32/asyncrequests.cxx
index 86b71cf51540..bfecc42125a3 100644
--- a/fpicker/source/win32/asyncrequests.cxx
+++ b/fpicker/source/win32/asyncrequests.cxx
@@ -50,7 +50,7 @@ void Request::wait( ::sal_Int32 nMilliSeconds )
 void Request::waitProcessMessages()
 {
     SolarMutexGuard aGuard;
-    while ( !m_aJoiner.check() )
+    while ( !m_aJoiner.check() && !Application::IsQuit())
         Application::Yield();
 }
 
diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx
index b6b4c7c34860..3821654df008 100644
--- a/framework/source/loadenv/loadenv.cxx
+++ b/framework/source/loadenv/loadenv.cxx
@@ -413,7 +413,7 @@ bool LoadEnv::waitWhileLoading(sal_uInt32 nTimeout)
     // in an intelligent manner :-)
 
     sal_Int32 nTime = nTimeout;
-    while(true)
+    while(!Application::IsQuit())
     {
         // SAFE -> ------------------------------
         {
diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx
index b0b5a069af4b..ab2af42dc41c 100644
--- a/include/vcl/svapp.hxx
+++ b/include/vcl/svapp.hxx
@@ -456,6 +456,10 @@ public:
     */
     static void                 Quit();
 
+    /** Has Quit() been called?
+    */
+    static bool                 IsQuit();
+
     /** Attempt to process current pending event(s)
 
      It doesn't sleep if no events are available for processing.
diff --git a/sc/source/filter/oox/workbookfragment.cxx b/sc/source/filter/oox/workbookfragment.cxx
index 3cccee89e6aa..e89f0c8458c3 100644
--- a/sc/source/filter/oox/workbookfragment.cxx
+++ b/sc/source/filter/oox/workbookfragment.cxx
@@ -328,7 +328,7 @@ void importSheetFragments( WorkbookFragment& rWorkbookHandler, SheetFragmentVect
     }
 
     // coverity[loop_top] - this isn't an infinite loop where nSheetsLeft gets decremented by the above threads
-    while( nSheetsLeft > 0)
+    while( nSheetsLeft > 0 && !Application::IsQuit())
     {
         // This is a much more controlled re-enterancy hazard than
         // allowing a yield deeper inside the filter code for progress
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 0908d025852d..8a961ce7627f 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -2737,7 +2737,7 @@ void SfxMedium::Download( const Link<void*,void>& aLink )
     GetInStream();
     if ( pImpl->m_pInStream && !aLink.IsSet() )
     {
-        while( !pImpl->bDownloadDone )
+        while( !pImpl->bDownloadDone && !Application::IsQuit())
             Application::Yield();
     }
 }
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 47c379a3a8f6..6ed21500a2a9 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -428,7 +428,7 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue >
 
     //wait until printing is done
     SfxPrinter* pDocPrinter = pViewSh->GetPrinter();
-    while ( pDocPrinter->IsPrinting() )
+    while ( pDocPrinter->IsPrinting() && !Application::IsQuit())
         Application::Yield();
 }
 
@@ -484,7 +484,7 @@ class ImplUCBPrintWatcher : public ::osl::Thread
             /* SAFE { */
             {
                 SolarMutexGuard aGuard;
-                while( m_pPrinter->IsPrinting() )
+                while( m_pPrinter->IsPrinting() && !Application::IsQuit())
                     Application::Yield();
                 m_pPrinter.clear(); // don't delete it! It's borrowed only :-)
             }
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index 1f40250ad065..596ba262c1d3 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -711,7 +711,7 @@ short RecoveryDialog::execute()
                 m_pCore->doRecovery();
 
                 m_bWaitForCore = true;
-                while(m_bWaitForCore)
+                while(m_bWaitForCore && !Application::IsQuit())
                     Application::Yield();
 
                 m_pCore->setUpdateListener(nullptr);
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index b7a4dda755c4..ef86d4dd4c78 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1612,7 +1612,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                     "sw::SwDBManager aEmailDispatcherPollTimer" );
                 aEmailDispatcherPollTimer.SetTimeout( 500 );
                 aEmailDispatcherPollTimer.Start();
-                while( IsMergeOk() && m_pImpl->m_xLastMessage.is() )
+                while( IsMergeOk() && m_pImpl->m_xLastMessage.is() && !Application::IsQuit())
                     Application::Yield();
                 aEmailDispatcherPollTimer.Stop();
             }
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index 17fc5ce651f0..28591b233092 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -435,7 +435,7 @@ void PrintPreviewHelper( const css::uno::Any& /*EnableChanges*/, SfxViewShell co
 
 void WaitUntilPreviewIsClosed( SfxViewFrame* pViewFrame )
 {
-    while ( pViewFrame && isInPrintPreview( pViewFrame ) )
+    while ( pViewFrame && isInPrintPreview( pViewFrame ) && !Application::IsQuit())
         Application::Yield();
 }
 
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx
index fb3cb8c56bcf..1f4f6e9e9de6 100644
--- a/vcl/source/app/svapp.cxx
+++ b/vcl/source/app/svapp.cxx
@@ -577,6 +577,11 @@ bool Application::IsInExecute()
     return ImplGetSVData()->maAppData.mbInAppExecute;
 }
 
+bool Application::IsQuit()
+{
+    return ImplGetSVData()->maAppData.mbAppQuit;
+}
+
 bool Application::IsInModalMode()
 {
     return (ImplGetSVData()->maAppData.mnModalMode != 0);
diff --git a/vcl/source/control/prgsbar.cxx b/vcl/source/control/prgsbar.cxx
index e861d66bcb03..ef8d2867018a 100644
--- a/vcl/source/control/prgsbar.cxx
+++ b/vcl/source/control/prgsbar.cxx
@@ -182,7 +182,7 @@ void ProgressBar::SetValue( sal_uInt16 nNewPercent )
         Idle aIdle("ProgressBar::SetValue aIdle");
         aIdle.SetPriority(TaskPriority::POST_PAINT);
         aIdle.Start();
-        while (aIdle.IsActive())
+        while (aIdle.IsActive() && !Application::IsQuit())
         {
             Application::Yield();
         }
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 92db0975c6c1..e18b9f18cd4b 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1053,7 +1053,7 @@ short Dialog::Execute()
 
     // Yield util EndDialog is called or dialog gets destroyed
     // (the latter should not happen, but better safe than sorry
-    while ( !xWindow->IsDisposed() && mbInExecute )
+    while ( !xWindow->IsDisposed() && mbInExecute && !Application::IsQuit() )
         Application::Yield();
 
     ImplEndExecuteModal();
diff --git a/vcl/source/window/menufloatingwindow.cxx b/vcl/source/window/menufloatingwindow.cxx
index cfcb58b8f63e..dd1e2c6ea557 100644
--- a/vcl/source/window/menufloatingwindow.cxx
+++ b/vcl/source/window/menufloatingwindow.cxx
@@ -455,7 +455,7 @@ void MenuFloatingWindow::Execute()
 
     Start();
 
-    while (bInExecute)
+    while (bInExecute && !Application::IsQuit())
         Application::Yield();
 
     pSVData->maAppData.mpActivePopupMenu = nullptr;
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 3ba8e96ce44e..64dd582f1277 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -1145,7 +1145,7 @@ void SystemWindow::ensureRepaint()
     Invalidate();
     mbPaintComplete = false;
 
-    while (!mbPaintComplete)
+    while (!mbPaintComplete && !Application::IsQuit())
     {
         Application::Yield();
     }


More information about the Libreoffice-commits mailing list