Commit 94e4285d authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Kurt Hindenburg
Browse files

Fix one crash in the sshmanager plugin

BUG: 439551
(cherry picked from commit 1946d32d)
parent 1dcc2e14
......@@ -11,6 +11,7 @@
#include "sshmanagermodel.h"
#include "session/SessionController.h"
#include "konsoledebug.h"
#include <QMainWindow>
#include <QDockWidget>
......@@ -78,12 +79,29 @@ QList<QAction *> SSHManagerPlugin::menuBarActions(Konsole::MainWindow* mainWindo
void SSHManagerPlugin::activeViewChanged(Konsole::SessionController *controller)
{
activeViewChangedInternal(QPointer(controller));
}
void SSHManagerPlugin::activeViewChangedInternal(QPointer<Konsole::SessionController> controller)
{
if (!controller) {
qCWarning(KonsoleDebug) << "Active view changed, but no controller";
return;
}
if (!controller->view()) {
qCWarning(KonsoleDebug) << controller << "does not have a view";
return;
}
auto mainWindow = qobject_cast<Konsole::MainWindow*>(controller->view()->topLevelWidget());
// if we don't get a mainwindow here this *might* be just opening, call it again
// HACK: if we don't get a mainwindow here this *might* be just opening, call it again
// later on.
// We really shouldn't use an arbitrary time delay, and we need to use a
// QPointer in case it gets deleted while the timer is running.
if (!mainWindow) {
QTimer::singleShot(500, this, [this, controller]{ activeViewChanged(controller); });
QTimer::singleShot(500, this, [this, controller]{ activeViewChangedInternal(controller); });
return;
}
......
......@@ -29,6 +29,9 @@ public:
void activeViewChanged(Konsole::SessionController *controller) override;
QList<QAction*> menuBarActions(Konsole::MainWindow* mainWindow) const override;
private Q_SLOTS:
void activeViewChangedInternal(QPointer<Konsole::SessionController> controller);
private:
std::unique_ptr<SSHManagerPluginPrivate> d;
};
......
Markdown is supported
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