From a366c7cffe263740107e06592b88301c7e0e8cb3 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Wed, 9 Aug 2023 14:42:03 -0400 Subject: [PATCH] Stop misleading error when recent project doesn't exist --- CHANGELOG.md | 1 + src/mainwindow.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6de13cb4..4cc36103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d ### Changed - The Palette Editor now remembers the Bit Depth setting. - The min/max levels on the Wild Pokémon tab will now adjust automatically if they invalidate each other. +- If the recent project directory doesn't exist Porymap will open an empty project instead of failing with a misleading error message. ### Fixed - Fix text boxes in the Palette Editor calculating color incorrectly. diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 52f210aa..c9aad46e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -483,12 +483,18 @@ bool MainWindow::openRecentProject() { return false; QString default_dir = porymapConfig.getRecentProject(); - if (!default_dir.isNull() && default_dir.length() > 0) { - logInfo(QString("Opening recent project: '%1'").arg(default_dir)); - return openProject(default_dir); + if (default_dir.isNull() || default_dir.length() <= 0) + return false; + + if (!QDir(default_dir).exists()) { + QString message = QString("Recent project directory '%1' doesn't exist.").arg(QDir::toNativeSeparators(default_dir)); + logWarn(message); + this->statusBar()->showMessage(message); + return false; } - return false; + logInfo(QString("Opening recent project: '%1'").arg(default_dir)); + return openProject(default_dir); } bool MainWindow::openProject(QString dir) {