From 45f332f61e687a01129d482c57c880ec7c2f7cac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 May 2015 06:45:01 +0200 Subject: main: error check for --autostart cmdline option Pointed-out-by: Fabian Wickborn --- facetracknoir/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index e8a29598..1abf5d6b 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -9,6 +9,7 @@ using namespace options; #include #include #include +#include #include #include @@ -24,9 +25,7 @@ static void add_program_library_path() char* ptr = strrchr(path, '\\'); if (ptr) { - printf("%s\n", path); *ptr = '\0'; - printf("%s\n", path); QCoreApplication::addLibraryPath(path); } } @@ -69,7 +68,13 @@ int main(int argc, char** argv) p.process(app); QString profile = p.value(autostartOption); - if (!profile.isEmpty()) + + bool use_profile = profile.endsWith(".ini") && QFileInfo(profile).exists() && QFileInfo(profile).isFile(); + if (!profile.isEmpty() && !use_profile) + QMessageBox::warning(nullptr, "Can't load profile", "Profile " + profile + " specified but can't be opened!", + QMessageBox::Ok, QMessageBox::NoButton); + + if (use_profile) { QSettings settings(group::org); settings.setValue(group::filename_key, MainWindow::remove_app_path(profile)); @@ -77,7 +82,7 @@ int main(int argc, char** argv) MainWindow w; - if (!profile.isEmpty()) + if (use_profile) w.startTracker(); w.show(); -- cgit v1.2.3