From 7c225873704686c48d39dba4a423758d92af0890 Mon Sep 17 00:00:00 2001 From: Nicolas Mailloux Date: Wed, 23 Mar 2022 22:09:37 -0400 Subject: [PATCH] Fix #19 & #21 (bookconfig_mount issue) --- reader.cpp | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/reader.cpp b/reader.cpp index 007ea29..86c9a66 100644 --- a/reader.cpp +++ b/reader.cpp @@ -177,13 +177,16 @@ reader::reader(QWidget *parent) : stylesheetFile.close(); book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); - if(book_file != "") { + if(!book_file.isEmpty()) { setDefaultWorkDir(); } else { // User clicked "Cancel" button + // Restarting InkBox setDefaultWorkDir(); - quit_restart(); + QProcess process; + process.startDetached("inkbox", QStringList()); + qApp->quit(); } } else { @@ -203,13 +206,16 @@ reader::reader(QWidget *parent) : stylesheetFile.close(); book_file = dialog->getOpenFileName(dialog, tr("Open File"), QDir::currentPath()); - if(book_file != "") { + if(!book_file.isEmpty()) { setDefaultWorkDir(); } else { // User clicked "Cancel" button + // Restarting InkBox setDefaultWorkDir(); - quit_restart(); + QProcess process; + process.startDetached("inkbox", QStringList()); + qApp->quit(); } } } @@ -220,20 +226,22 @@ reader::reader(QWidget *parent) : string_writeconfig("/tmp/inkboxBookPath", book_file_str); // Calling InkBox daemon (ibxd) via FIFO interface to run bookconfig_mount - if(checkconfig(".config/16-global_reading_settings/config") == false) { - global::reader::globalReadingSettings = false; - string_writeconfig("/opt/ibxd", "bookconfig_mount\n"); - // Callback handler to wait until bookconfig_mount has finished execution - while(true) { - if(QFile::exists("/inkbox/bookConfigSetUp")) { - QFile::remove("/inkbox/bookConfigSetUp"); - setupLocalSettingsEnvironment(); - break; + if(!book_file.isEmpty()) { + if(checkconfig(".config/16-global_reading_settings/config") == false) { + global::reader::globalReadingSettings = false; + string_writeconfig("/opt/ibxd", "bookconfig_mount\n"); + // Callback handler to wait until bookconfig_mount has finished execution + while(true) { + if(QFile::exists("/inkbox/bookConfigSetUp")) { + QFile::remove("/inkbox/bookConfigSetUp"); + setupLocalSettingsEnvironment(); + break; + } } } - } - else { - global::reader::globalReadingSettings = true; + else { + global::reader::globalReadingSettings = true; + } } // Custom settings