mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Fix NewFileDialog leaking MainWindow
This also fixes segfaults on quitting when using plugins
This commit is contained in:
parent
48260cc534
commit
7a77eeee06
@ -472,7 +472,7 @@ void MainWindow::displayWelcomeDialog()
|
|||||||
|
|
||||||
void MainWindow::displayNewFileDialog()
|
void MainWindow::displayNewFileDialog()
|
||||||
{
|
{
|
||||||
NewFileDialog *n = new NewFileDialog();
|
NewFileDialog *n = new NewFileDialog(this);
|
||||||
newFileDialog = n;
|
newFileDialog = n;
|
||||||
n->setAttribute(Qt::WA_DeleteOnClose);
|
n->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
n->show();
|
n->show();
|
||||||
|
@ -423,6 +423,5 @@ void InitialOptionsDialog::on_scriptSelectButton_clicked()
|
|||||||
void InitialOptionsDialog::reject()
|
void InitialOptionsDialog::reject()
|
||||||
{
|
{
|
||||||
done(0);
|
done(0);
|
||||||
NewFileDialog *n = new NewFileDialog(nullptr);
|
main->displayNewFileDialog();
|
||||||
n->show();
|
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,10 @@ static QIcon getIconFor(const QString &str, int pos)
|
|||||||
return QIcon(pixmap);
|
return QIcon(pixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFileDialog::NewFileDialog(QWidget *parent) :
|
NewFileDialog::NewFileDialog(MainWindow *main) :
|
||||||
QDialog(parent),
|
QDialog(main),
|
||||||
ui(new Ui::NewFileDialog)
|
ui(new Ui::NewFileDialog),
|
||||||
|
main(main)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
@ -359,7 +360,6 @@ void NewFileDialog::loadFile(const QString &filename)
|
|||||||
settings.setValue("recentFileList", files);
|
settings.setValue("recentFileList", files);
|
||||||
|
|
||||||
// Close dialog and open MainWindow/InitialOptionsDialog
|
// Close dialog and open MainWindow/InitialOptionsDialog
|
||||||
MainWindow *main = new MainWindow();
|
|
||||||
QString ioFile = "";
|
QString ioFile = "";
|
||||||
if (ui->ioPlugin->currentIndex()) {
|
if (ui->ioPlugin->currentIndex()) {
|
||||||
ioFile = ui->ioPlugin->currentText() + "://";
|
ioFile = ui->ioPlugin->currentText() + "://";
|
||||||
|
@ -9,12 +9,14 @@ namespace Ui {
|
|||||||
class NewFileDialog;
|
class NewFileDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
class NewFileDialog : public QDialog
|
class NewFileDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NewFileDialog(QWidget *parent = nullptr);
|
explicit NewFileDialog(MainWindow *main);
|
||||||
~NewFileDialog();
|
~NewFileDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@ -46,6 +48,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::NewFileDialog> ui;
|
std::unique_ptr<Ui::NewFileDialog> ui;
|
||||||
|
|
||||||
|
MainWindow *main;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true if list is not empty
|
* @return true if list is not empty
|
||||||
*/
|
*/
|
||||||
|
@ -6,8 +6,8 @@ from PySide2.QtWidgets import QAction, QVBoxLayout, QLabel, QWidget, QSizePolicy
|
|||||||
|
|
||||||
|
|
||||||
class FortuneWidget(cutter.CutterDockWidget):
|
class FortuneWidget(cutter.CutterDockWidget):
|
||||||
def __init__(self, main, action):
|
def __init__(self, parent, action):
|
||||||
super(FortuneWidget, self).__init__(main, action)
|
super(FortuneWidget, self).__init__(parent, action)
|
||||||
self.setObjectName("FancyDockWidgetFromCoolPlugin")
|
self.setObjectName("FancyDockWidgetFromCoolPlugin")
|
||||||
self.setWindowTitle("Sample Python Plugin")
|
self.setWindowTitle("Sample Python Plugin")
|
||||||
|
|
||||||
@ -54,10 +54,10 @@ class CutterSamplePlugin(cutter.CutterPlugin):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def setupInterface(self, main):
|
def setupInterface(self, main):
|
||||||
self.action = QAction("Sample Python Plugin", main)
|
action = QAction("Sample Python Plugin", main)
|
||||||
self.action.setCheckable(True)
|
action.setCheckable(True)
|
||||||
self.widget = FortuneWidget(main, self.action) # we MUST keep a reference to this!
|
widget = FortuneWidget(main, action)
|
||||||
main.addPluginDockWidget(self.widget, self.action)
|
main.addPluginDockWidget(widget, action)
|
||||||
|
|
||||||
|
|
||||||
# This function will be called by Cutter and should return an instance of the plugin.
|
# This function will be called by Cutter and should return an instance of the plugin.
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
#include "core/MainWindow.h"
|
#include "core/MainWindow.h"
|
||||||
|
|
||||||
|
|
||||||
CutterDockWidget::CutterDockWidget(MainWindow *main, QAction *action) :
|
CutterDockWidget::CutterDockWidget(MainWindow *parent, QAction *action) :
|
||||||
QDockWidget(main),
|
QDockWidget(parent),
|
||||||
action(action)
|
action(action)
|
||||||
{
|
{
|
||||||
if (action) {
|
if (action) {
|
||||||
main->addToDockWidgetList(this);
|
parent->addToDockWidgetList(this);
|
||||||
main->addDockWidgetAction(this, action);
|
parent->addDockWidgetAction(this, action);
|
||||||
connect(action, &QAction::triggered, this, &CutterDockWidget::toggleDockWidget);
|
connect(action, &QAction::triggered, this, &CutterDockWidget::toggleDockWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class CutterDockWidget : public QDockWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CutterDockWidget(MainWindow *main, QAction *action = nullptr);
|
explicit CutterDockWidget(MainWindow *parent, QAction *action = nullptr);
|
||||||
~CutterDockWidget() override;
|
~CutterDockWidget() override;
|
||||||
bool eventFilter(QObject *object, QEvent *event) override;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
bool isVisibleToUser() { return isVisibleToUserCurrent; }
|
bool isVisibleToUser() { return isVisibleToUserCurrent; }
|
||||||
|
Loading…
Reference in New Issue
Block a user