[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - vcl/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Sat Sep 28 07:24:59 UTC 2019


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

New commits:
commit 4faf8989c52eaa21c3f4a9e7b30e014d9fb01c6d
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Sep 27 22:04:49 2019 +0100
Commit:     Michael Meeks <michael.meeks at 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 <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at 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 )


More information about the Libreoffice-commits mailing list