Commit 727e9e88 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

Fix replicode plugin not deleting its toolview

BUG: 441859
(cherry picked from commit e16167da)
parent c75b6a75
......@@ -133,7 +133,7 @@ KateCTagsView::KateCTagsView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
KMessageBox::sorry(nullptr, error);
});
m_gotoSymbWidget = new GotoSymbolWidget(mainWin, this);
m_gotoSymbWidget.reset(new GotoSymbolWidget(mainWin, this));
auto openLocal = actionCollection()->addAction(QStringLiteral("open_local_gts"));
openLocal->setText(i18n("Go To Local Symbol"));
actionCollection()->setDefaultShortcut(openLocal, Qt::CTRL | Qt::ALT | Qt::Key_P);
......
......@@ -103,7 +103,7 @@ private:
QPointer<KTextEditor::MainWindow> m_mWin;
QPointer<QWidget> m_toolView;
Ui::kateCtags m_ctagsUi{};
GotoSymbolWidget *m_gotoSymbWidget;
std::unique_ptr<GotoSymbolWidget> m_gotoSymbWidget;
QPointer<KActionMenu> m_menu;
QAction *m_gotoDef;
......
......@@ -46,22 +46,22 @@ ReplicodeView::ReplicodeView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
actionCollection()->addAction(QStringLiteral("katereplicode_stop"), m_stopAction);
m_stopAction->setEnabled(false);
m_toolview = m_mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katereplicodeplugin_run"),
KTextEditor::MainWindow::Bottom,
QIcon::fromTheme(QStringLiteral("code-block")),
i18n("Replicode Output"));
m_replicodeOutput = new QListWidget(m_toolview);
m_toolview.reset(m_mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katereplicodeplugin_run"),
KTextEditor::MainWindow::Bottom,
QIcon::fromTheme(QStringLiteral("code-block")),
i18n("Replicode Output")));
m_replicodeOutput = new QListWidget(m_toolview.get());
m_replicodeOutput->setSelectionMode(QAbstractItemView::ContiguousSelection);
connect(m_replicodeOutput, &QListWidget::itemActivated, this, &ReplicodeView::outputClicked);
m_mainWindow->hideToolView(m_toolview);
m_mainWindow->hideToolView(m_toolview.get());
m_configSidebar = m_mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katereplicodeplugin_config"),
KTextEditor::MainWindow::Right,
QIcon::fromTheme(QStringLiteral("code-block")),
i18n("Replicode Config"));
m_configView = new ReplicodeConfig(m_configSidebar);
m_configSidebar.reset(m_mainWindow->createToolView(plugin,
QStringLiteral("kate_private_plugin_katereplicodeplugin_config"),
KTextEditor::MainWindow::Right,
QIcon::fromTheme(QStringLiteral("code-block")),
i18n("Replicode Config")));
m_configView = new ReplicodeConfig(m_configSidebar.get());
m_runButton = new QPushButton(i18nc("shortcut for action", "Run (%1)", m_runAction->shortcut().toString()));
m_stopButton = new QPushButton(i18nc("shortcut for action", "Stop (%1)", m_stopAction->shortcut().toString()));
......@@ -79,24 +79,24 @@ ReplicodeView::ReplicodeView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
ReplicodeView::~ReplicodeView()
{
m_mainWindow->guiFactory()->removeClient(this);
delete m_executor;
m_mainWindow->guiFactory()->removeClient(this);
}
void ReplicodeView::viewChanged()
{
if (m_mainWindow->activeView() && m_mainWindow->activeView()->document()
&& m_mainWindow->activeView()->document()->url().fileName().endsWith(QLatin1String(".replicode"))) {
m_mainWindow->showToolView(m_configSidebar);
m_mainWindow->showToolView(m_configSidebar.get());
} else {
m_mainWindow->hideToolView(m_configSidebar);
m_mainWindow->hideToolView(m_toolview);
m_mainWindow->hideToolView(m_configSidebar.get());
m_mainWindow->hideToolView(m_toolview.get());
}
}
void ReplicodeView::runReplicode()
{
m_mainWindow->showToolView(m_toolview);
m_mainWindow->showToolView(m_toolview.get());
KTextEditor::View *editor = m_mainWindow->activeView();
if (!editor || !editor->document()) {
QMessageBox::warning(m_mainWindow->window(), i18nc("@title:window", "Active Document Not Found"), i18n("Could not find an active document to run."));
......
......@@ -49,8 +49,8 @@ private:
KTextEditor::MainWindow *m_mainWindow;
QProcess *m_executor;
QListWidget *m_replicodeOutput;
QWidget *m_toolview;
QWidget *m_configSidebar;
std::unique_ptr<QWidget> m_toolview;
std::unique_ptr<QWidget> m_configSidebar;
QPushButton *m_runButton;
QPushButton *m_stopButton;
QAction *m_runAction;
......
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