Resolves: tdf#127904 modal depth dips below 0

when validation dialog is run modally, but changed itself to unmodal
during execution.

only NotifyModalHierarchy on modal<->unmodal transition and not on
modality depth

Change-Id: I85d4f67e5b0426aafbf80b1ae25fc3e3f19717af
Reviewed-on: https://gerrit.libreoffice.org/80039
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index e31fb23..7b5356b 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3537,8 +3537,9 @@ struct DialogRunner
        if (m_xFrameWindow)
        {
            m_xFrameWindow->IncModalCount();
            if (m_nModalDepth == 0)
                m_xFrameWindow->ImplGetFrame()->NotifyModalHierarchy(true);
            ++m_nModalDepth;
            m_xFrameWindow->ImplGetFrame()->NotifyModalHierarchy(true);
        }
    }

@@ -3548,7 +3549,8 @@ struct DialogRunner
        {
            m_xFrameWindow->DecModalCount();
            --m_nModalDepth;
            m_xFrameWindow->ImplGetFrame()->NotifyModalHierarchy(false);
            if (m_nModalDepth == 0)
                m_xFrameWindow->ImplGetFrame()->NotifyModalHierarchy(false);
        }
    }

@@ -3608,13 +3610,8 @@ struct DialogRunner
            // if, like the calc validation dialog does, the modality was
            // toggled off during execution ensure that on cleanup the parent
            // is left in the state it was found
            SalFrame* pFrame = m_xFrameWindow->ImplGetFrame();
            do
            {
            while (m_nModalDepth++ < 0)
                m_xFrameWindow->IncModalCount();
                pFrame->NotifyModalHierarchy(true);
            }
            while (++m_nModalDepth < 0);
        }
    }
};