fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 184f118ae3eacf88c535c2ab5c0754870f6e2fa8
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Tue Feb 23 10:28:18 2021 +0100
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Fri Feb 26 00:32:00 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/+/111423
    Tested-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx 
b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
index 598f42a6f58f..a88c40a351aa 100644
--- a/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
+++ b/fpicker/source/win32/filepicker/VistaFilePickerImpl.cxx
@@ -177,6 +177,7 @@ VistaFilePickerImpl::VistaFilePickerImpl()
     , m_iEventHandler(new VistaFilePickerEventHandler(this))
     , m_bInExecute   (false)
     , m_bWasExecuted (false)
+    , m_hParentWindow(nullptr)
     , m_sDirectory   ()
     , m_sFilename    ()
 {
@@ -1023,17 +1024,24 @@ 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(...)
     {}
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to