diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-09-27 22:04:49 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-09-28 10:59:26 +0200 |
commit | ab09184efffdd70c5c89f20895132c7900777f7d (patch) | |
tree | f25dcd543089c6ec3fb3905193ec59a834058a31 | |
parent | 7d30fd55813a035a10715d92474df482b11782a7 (diff) |
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@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/79778
Tested-by: Jenkins
-rw-r--r-- | vcl/source/window/dialog.cxx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 1748abd0272a..080b64416e01 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1163,13 +1163,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; @@ -1177,12 +1177,15 @@ void Dialog::EndDialog( long nResult ) mbInExecute = false; - // Destroy ourselves (if we have a context with VclPtr owner) - std::shared_ptr<weld::DialogController> xOwnerDialogController = std::move(mpDialogImpl->maEndCtx.mxOwnerDialogController); - std::shared_ptr<weld::Dialog> xOwnerSelf = std::move(mpDialogImpl->maEndCtx.mxOwnerSelf); - mpDialogImpl->maEndCtx.mxOwner.disposeAndClear(); - xOwnerDialogController.reset(); - xOwnerSelf.reset(); + if ( mpDialogImpl ) + { + // Destroy ourselves (if we have a context with VclPtr owner) + std::shared_ptr<weld::DialogController> xOwnerDialogController = std::move(mpDialogImpl->maEndCtx.mxOwnerDialogController); + std::shared_ptr<weld::Dialog> xOwnerSelf = std::move(mpDialogImpl->maEndCtx.mxOwnerSelf); + mpDialogImpl->maEndCtx.mxOwner.disposeAndClear(); + xOwnerDialogController.reset(); + xOwnerSelf.reset(); + } } void Dialog::EndAllDialogs( vcl::Window const * pParent ) |