From 3ee8c68a4a696b2ab05e2d2edfabb35ce6fff94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Sun, 26 Nov 2017 13:36:24 +0100 Subject: [PATCH] Fix a crash and quitting accidentally --- src/dialogs/NewFileDialog.cpp | 8 ++++---- src/widgets/CodeGraphic.cpp | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/dialogs/NewFileDialog.cpp b/src/dialogs/NewFileDialog.cpp index 4a4c89f9..4bde181c 100644 --- a/src/dialogs/NewFileDialog.cpp +++ b/src/dialogs/NewFileDialog.cpp @@ -298,20 +298,20 @@ void NewFileDialog::loadFile(const QString &filename) settings.setValue("recentFileList", files); - close(); - // Close dialog and open MainWindow/OptionsDialog MainWindow *main = new MainWindow(); main->openNewFile(filename); //OptionsDialog *o = new OptionsDialog(fname); //o->exec(); + + close(); } } void NewFileDialog::loadProject(const QString &project) { - close(); - MainWindow *main = new MainWindow(); main->openProject(project); + + close(); } diff --git a/src/widgets/CodeGraphic.cpp b/src/widgets/CodeGraphic.cpp index 41c74cab..bd388568 100644 --- a/src/widgets/CodeGraphic.cpp +++ b/src/widgets/CodeGraphic.cpp @@ -79,7 +79,12 @@ void GraphicsBar::fillData() int to = mainMap["to"].toInt(); int block = mainMap["blocksize"].toInt(); int size = (to - from); - int num = size / block; + int num = 1; + if (block != 0) + { + num = size / block; + } + if (num < 1) { num = 1;