tdf#143534 Crash in Calc NLP Solver

prevent dialog from being deleted out from underneath
the code handling the dialog.

Change-Id: Ib1ef05f897901089708188820a3330dbeabc24c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120175
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/sc/source/ui/miscdlgs/optsolver.cxx b/sc/source/ui/miscdlgs/optsolver.cxx
index 3476efa..445c43a 100644
--- a/sc/source/ui/miscdlgs/optsolver.cxx
+++ b/sc/source/ui/miscdlgs/optsolver.cxx
@@ -507,6 +507,7 @@ bool ScOptSolverDlg::IsRefInputMode() const

IMPL_LINK(ScOptSolverDlg, BtnHdl, weld::Button&, rBtn, void)
{
    auto xKeepAlive = shared_from_this();
    if (&rBtn == m_xBtnSolve.get() || &rBtn == m_xBtnClose.get())
    {
        bool bSolve = ( &rBtn == m_xBtnSolve.get() );