mirror of
https://github.com/rizinorg/cutter.git
synced 2025-01-19 02:48:49 +00:00
Properly delete MainWindow
This commit is contained in:
parent
a0a3f9278d
commit
8c3d8d77cb
@ -64,9 +64,7 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow *main = new MainWindow();
|
||||
|
||||
setMainWindow(main);
|
||||
mainWindow = new MainWindow();
|
||||
|
||||
if (args.empty())
|
||||
{
|
||||
@ -76,19 +74,28 @@ CutterApplication::CutterApplication(int &argc, char **argv) : QApplication(argc
|
||||
exit(1);
|
||||
}
|
||||
|
||||
main->displayNewFileDialog();
|
||||
mainWindow->displayNewFileDialog();
|
||||
}
|
||||
else // filename specified as positional argument
|
||||
{
|
||||
main->openNewFile(args[0], analLevelSpecified ? analLevel : -1);
|
||||
mainWindow->openNewFile(args[0], analLevelSpecified ? analLevel : -1);
|
||||
}
|
||||
}
|
||||
|
||||
bool CutterApplication::event(QEvent *e){
|
||||
if (e->type() == QEvent::FileOpen) {
|
||||
CutterApplication::~CutterApplication()
|
||||
{
|
||||
delete mainWindow;
|
||||
}
|
||||
|
||||
bool CutterApplication::event(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::FileOpen)
|
||||
{
|
||||
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(e);
|
||||
if (openEvent) {
|
||||
if (m_FileAlreadyDropped) {
|
||||
if (openEvent)
|
||||
{
|
||||
if (m_FileAlreadyDropped)
|
||||
{
|
||||
// we already dropped a file in macOS, let's spawn another instance
|
||||
// (Like the File -> Open)
|
||||
QString fileName = openEvent->file();
|
||||
@ -96,11 +103,13 @@ bool CutterApplication::event(QEvent *e){
|
||||
process.setEnvironment(QProcess::systemEnvironment());
|
||||
QStringList args = QStringList(fileName);
|
||||
process.startDetached(qApp->applicationFilePath(), args);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
QString fileName = openEvent->file();
|
||||
m_FileAlreadyDropped = true;
|
||||
m_MainWindow->closeNewFileDialog();
|
||||
m_MainWindow->openNewFile(fileName, -1);
|
||||
mainWindow->closeNewFileDialog();
|
||||
mainWindow->openNewFile(fileName, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,25 +10,19 @@
|
||||
class CutterApplication : public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(MainWindow* mainWindow READ mainWindow WRITE setMainWindow)
|
||||
|
||||
public:
|
||||
CutterApplication(int &argc, char **argv);
|
||||
~CutterApplication();
|
||||
|
||||
MainWindow * mainWindow() {
|
||||
return m_MainWindow;
|
||||
}
|
||||
|
||||
void setMainWindow(MainWindow * mw) {
|
||||
m_MainWindow = mw;
|
||||
}
|
||||
MainWindow *getMainWindow() { return mainWindow; }
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
private:
|
||||
bool m_FileAlreadyDropped;
|
||||
MainWindow *m_MainWindow;
|
||||
MainWindow *mainWindow;
|
||||
};
|
||||
|
||||
#endif // CUTTERAPPLICATION_H
|
||||
|
Loading…
Reference in New Issue
Block a user