Commit 5aa3b009 authored by Dominik Haumann's avatar Dominik Haumann
Browse files

Fix crash when pressing ESC after external tools plugin was un/reloaded

The new conntect() syntax along with a lambda is not automatically
destroyed when the plugin is unloaded, since the connection does not
track the "this" pointer that is captured in the lambda function,
a typicall programming error :-/

This change turns the connection into a proper member function, so
the connection is cleaned up when the plugin view is deleted.

FIXED-IN: 19.12.1
parent 1f614a19
......@@ -160,12 +160,7 @@ KateExternalToolsPluginView::KateExternalToolsPluginView(KTextEditor::MainWindow
mainWindow->guiFactory()->addClient(this);
// ESC should close & hide ToolView
connect(m_mainWindow, &KTextEditor::MainWindow::unhandledShortcutOverride, [this](QEvent *event) {
auto keyEvent = static_cast<QKeyEvent *>(event);
if (keyEvent->key() == Qt::Key_Escape && keyEvent->modifiers() == Qt::NoModifier) {
deleteToolView();
}
});
connect(m_mainWindow, &KTextEditor::MainWindow::unhandledShortcutOverride, this, &KateExternalToolsPluginView::handleEsc);
}
KateExternalToolsPluginView::~KateExternalToolsPluginView()
......@@ -266,6 +261,15 @@ void KateExternalToolsPluginView::deleteToolView()
m_toolView = nullptr;
}
}
void KateExternalToolsPluginView::handleEsc(QEvent *event)
{
auto keyEvent = dynamic_cast<QKeyEvent *>(event);
if (keyEvent && keyEvent->key() == Qt::Key_Escape && keyEvent->modifiers() == Qt::NoModifier) {
deleteToolView();
}
}
// END KateExternalToolsPluginView
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -142,6 +142,11 @@ public Q_SLOTS:
*/
void deleteToolView();
/**
* On Escape, hide tool view.
*/
void handleEsc(QEvent *event);
private:
KateExternalToolsPlugin *m_plugin;
KTextEditor::MainWindow *m_mainWindow;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment