From e30fa7bc0c73f4ba02d33317bece34e9f1d75416 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 9 Jan 2022 17:42:23 -0800 Subject: [PATCH] - fix: crash when closing the options dialog under Ubuntu 20.04 LTS ( no memory leak now) --- RedPandaIDE/RedPandaIDE.pro | 10 ---------- RedPandaIDE/editor.cpp | 14 +++++++------- RedPandaIDE/settingsdialog/settingsdialog.cpp | 10 +--------- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 3fc211a2..ed81d751 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -19,16 +19,6 @@ DEFINES += PREFIX=\\\"$${PREFIX}\\\" DEFINES += APP_NAME=\\\"$${APP_NAME}\\\" DEFINES += REDPANDA_CPP_VERSION=\\\"$${APP_VERSION}\\\" -linux: { - LINUX_DISTRO = $$system(cat /etc/issue) - contains(LINUX_DISTRO, .*Ubuntu.*){ - contains(LINUX_DISTRO, .*20\.04.*) { - message("Found Ubuntu 20.04") - DEFINES += SETTINGS_DIALOG_FIX - } - } -} - gcc { QMAKE_CXXFLAGS_RELEASE += -Werror=return-type QMAKE_CXXFLAGS_DEBUG += -Werror=return-type diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8b3ce5db..212df608 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) * * This program is free software: you can redistribute it and/or modify @@ -183,14 +183,14 @@ Editor::Editor(QWidget *parent, const QString& filename, } Editor::~Editor() { - pMainWindow->fileSystemWatcher()->removePath(mFilename); - pMainWindow->caretList().removeEditor(this); - pMainWindow->updateCaretActions(); - if (mParentPageControl!=nullptr) { + if (mParentPageControl) { + pMainWindow->fileSystemWatcher()->removePath(mFilename); + pMainWindow->caretList().removeEditor(this); + pMainWindow->updateCaretActions(); int index = mParentPageControl->indexOf(this); mParentPageControl->removeTab(index); + this->setParent(nullptr); } - this->setParent(nullptr); } void Editor::loadFile(QString filename) { @@ -1522,7 +1522,7 @@ void Editor::onStatusChanged(SynStatusChanges changes) pMainWindow->updateEditorActions(); - if (changes.testFlag(SynStatusChange::scCaretY)) { + if (changes.testFlag(SynStatusChange::scCaretY) && mParentPageControl) { pMainWindow->caretList().addCaret(this,caretY(),caretX()); pMainWindow->updateCaretActions(); } diff --git a/RedPandaIDE/settingsdialog/settingsdialog.cpp b/RedPandaIDE/settingsdialog/settingsdialog.cpp index b1e3a4fe..1fcc372d 100644 --- a/RedPandaIDE/settingsdialog/settingsdialog.cpp +++ b/RedPandaIDE/settingsdialog/settingsdialog.cpp @@ -88,13 +88,6 @@ SettingsDialog::~SettingsDialog() { for (SettingsWidget* p:mSettingWidgets) { p->setParent(nullptr); - //dirty fix for ubuntu 20.04 LTS -#ifdef SETTINGS_DIALOG_FIX - if (p->group()==tr("Editor") && p->name()==tr("Color")) - continue; - if (p->group()==tr("Editor") && p->name()==tr("Snippet")) - continue; -#endif delete p; } delete ui; @@ -152,12 +145,11 @@ PSettingsDialog SettingsDialog::optionDialog() dialog->addWidget(widget); widget = new EnvironmentFoldersWidget(tr("Folders"),tr("Environment")); - dialog->addWidget(widget); - connect((EnvironmentFoldersWidget*)widget, &EnvironmentFoldersWidget::shouldQuitApp, dialog.get(), &SettingsDialog::closeAndQuit); + dialog->addWidget(widget); #ifdef Q_OS_LINUX widget = new EnvironmentProgramsWidget(tr("Terminal"),tr("Environment"));