vcl/source/window/dialog.cxx |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

New commits:
commit 4faf8989c52eaa21c3f4a9e7b30e014d9fb01c6d
Author:     Michael Meeks <michael.me...@collabora.com>
AuthorDate: Fri Sep 27 22:04:49 2019 +0100
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Sat Sep 28 09:24:24 2019 +0200

    Avoid lambda being destroyed while it is being called.
    
    Also armor against mpDialogImpl going down during EndDialog.
    This can happen during an insert chart wizard cancel, as
    out of place embedded dialog cleanup occurs.
    
    Change-Id: I1b666f07d4ec72e07fdf6888cea44a5a13976073
    Reviewed-on: https://gerrit.libreoffice.org/79772
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 1f912fff6cdb..b5d1b013b97e 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1179,13 +1179,13 @@ void Dialog::EndDialog( long nResult )
     if ( mpDialogImpl->mbStartedModal )
         ImplEndExecuteModal();
 
-    if (mpDialogImpl->maEndCtx.isSet())
+    if ( mpDialogImpl && mpDialogImpl->maEndCtx.isSet() )
     {
-        mpDialogImpl->maEndCtx.maEndDialogFn(nResult);
-        mpDialogImpl->maEndCtx.maEndDialogFn = nullptr;
+        auto fn = std::move(mpDialogImpl->maEndCtx.maEndDialogFn);
+        fn(nResult);
     }
 
-    if ( mpDialogImpl->mbStartedModal )
+    if ( mpDialogImpl && mpDialogImpl->mbStartedModal )
     {
         mpDialogImpl->mbStartedModal = false;
         mpDialogImpl->mnResult = -1;
@@ -1193,10 +1193,13 @@ void Dialog::EndDialog( long nResult )
 
     mbInExecute = false;
 
-    // Destroy ourselves (if we have a context with VclPtr owner)
-    std::shared_ptr<weld::DialogController> xOwnerDialog = 
std::move(mpDialogImpl->maEndCtx.mxOwnerDialog);
-    mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
-    xOwnerDialog.reset();
+    if ( mpDialogImpl )
+    {
+        // Destroy ourselves (if we have a context with VclPtr owner)
+        std::shared_ptr<weld::DialogController> xOwnerDialog = 
std::move(mpDialogImpl->maEndCtx.mxOwnerDialog);
+        mpDialogImpl->maEndCtx.mxOwner.disposeAndClear();
+        xOwnerDialog.reset();
+    }
 }
 
 void Dialog::EndAllDialogs( vcl::Window const * pParent )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to