[Libreoffice-commits] core.git: Branch 'libreoffice-7-0-5' - fpicker/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 2 18:30:16 UTC 2021


 fpicker/source/win32/VistaFilePickerImpl.cxx |   16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit f78648cdb3672972c47f59256305623d8ff5f444
Author:     Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
AuthorDate: Tue Feb 23 10:28:18 2021 +0100
Commit:     Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
CommitDate: Tue Mar 2 19:29:33 2021 +0100

    Possible race between retrieving and using parent window
    
    Filepicker was called from extension, parent window was initialized in constructor
    with current top level window (extension dialog).
    Extension dialog got closed before file picker was shown in some cases,
    causing Show() method to fail
    
    Change-Id: Ie41585e6b05511ba2dff265374348b6041e9fa87
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111378
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt at allotropia.de>
    (cherry picked from commit 8c62c2fb88a7a82939ad3b5c7355c93a41b76d5b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111588
    Reviewed-by: Michael Stahl <michael.stahl at allotropia.de>
    Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
    Tested-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>

diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx b/fpicker/source/win32/VistaFilePickerImpl.cxx
index c84fe5f3a72d..4be9c0737aa4 100644
--- a/fpicker/source/win32/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/VistaFilePickerImpl.cxx
@@ -187,7 +187,7 @@ VistaFilePickerImpl::VistaFilePickerImpl()
     , m_iEventHandler(new VistaFilePickerEventHandler(this))
     , m_bInExecute   (false)
     , m_bWasExecuted (false)
-    , m_hParentWindow(choose_parent_window())
+    , m_hParentWindow(nullptr)
     , m_sDirectory   ()
     , m_sFilename    ()
 {
@@ -1026,19 +1026,25 @@ void VistaFilePickerImpl::impl_sta_ShowDialogModal(const RequestRef& rRequest)
         }
     }
 
-
     HRESULT hResult = E_FAIL;
+    HWND hParentWindow;
+    {
+        osl::MutexGuard aLock(m_aMutex);
+        // Note that there is a potential race between retrieving and
+        // using parent window (window might get destroyed)
+        hParentWindow = m_hParentWindow ? m_hParentWindow : choose_parent_window();
+    }
     try
     {
         // show dialog and wait for user decision
         if (iOpen.is())
-            hResult = iOpen->Show( m_hParentWindow ); // parent window needed
+            hResult = iOpen->Show( hParentWindow ); // parent window needed
         else
         if (iSave.is())
-            hResult = iSave->Show( m_hParentWindow ); // parent window needed
+            hResult = iSave->Show( hParentWindow ); // parent window needed
         else
         if (iPick.is())
-            hResult = iPick->Show( m_hParentWindow ); // parent window needed
+            hResult = iPick->Show( hParentWindow ); // parent window needed
     }
     catch(...)
     {}


More information about the Libreoffice-commits mailing list