From eea8f42ea4ccce7195afa03733e46185339cec2a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 8 Aug 2023 18:51:02 +0200 Subject: [PATCH] VcsBase: Move listening to closing submit editors into plugins Change-Id: Iaab385621f84bcb6e1f6e79cffc198fbd0554c30 Reviewed-by: Jarek Kobus --- src/plugins/vcsbase/vcsbaseplugin.cpp | 18 ++++++++---------- src/plugins/vcsbase/vcsplugin.cpp | 7 ------- src/plugins/vcsbase/vcsplugin.h | 3 --- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 930f54472a4..33ea3872a2d 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -489,9 +489,6 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state) When triggering an action, a copy of the state should be made to keep it, as it may rapidly change due to context changes, etc. - - The class also detects the VCS plugin submit editor closing and calls - the virtual submitEditorAboutToClose() to trigger the submit process. */ bool VcsBasePluginPrivate::supportsRepositoryCreation() const @@ -504,18 +501,19 @@ static Internal::StateListener *m_listener = nullptr; VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context) : m_context(context) { - Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance(); - connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose, - this, [this](VcsBaseSubmitEditor *submitEditor, bool *result) { - if (submitEditor == m_submitEditor) { - *result = submitEditor->promptSubmit(this); - if (*result) + EditorManager::addCloseEditorListener([this](IEditor *editor) { + bool result = true; + if (editor == m_submitEditor) { + result = m_submitEditor->promptSubmit(this); + if (result) discardCommit(); } + return result; }); + // First time: create new listener if (!m_listener) - m_listener = new Internal::StateListener(plugin); + m_listener = new Internal::StateListener(Internal::VcsPlugin::instance()); connect(m_listener, &Internal::StateListener::stateChanged, this, &VcsBasePluginPrivate::slotStateChanged); // VCSes might have become (un-)available, so clear the VCS directory cache diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp index ee6461e603f..553bfc61a69 100644 --- a/src/plugins/vcsbase/vcsplugin.cpp +++ b/src/plugins/vcsbase/vcsplugin.cpp @@ -96,13 +96,6 @@ void VcsPlugin::initialize() { d = new VcsPluginPrivate(this); - EditorManager::addCloseEditorListener([this](IEditor *editor) -> bool { - bool result = true; - if (auto se = qobject_cast(editor)) - emit submitEditorAboutToClose(se, &result); - return result; - }); - JsExpander::registerGlobalObject("Vcs"); MacroExpander *expander = globalMacroExpander(); diff --git a/src/plugins/vcsbase/vcsplugin.h b/src/plugins/vcsbase/vcsplugin.h index 44be10b23e0..da738701928 100644 --- a/src/plugins/vcsbase/vcsplugin.h +++ b/src/plugins/vcsbase/vcsplugin.h @@ -33,9 +33,6 @@ public: // initialization and updating on settings change. QStandardItemModel *nickNameModel(); -signals: - void submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *e, bool *result); - private: class VcsPluginPrivate *d = nullptr; };