summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2016-08-27 15:41:51 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2016-08-27 15:41:51 (GMT)
commitd73270a470680e4b796372a3196d15053d50029b (patch)
tree461695e62237af3072fd4189c36cd55b3ea603c7
parentb2b852cfd7b10fc2ffb668ac87f8ca9236a134e3 (diff)
Fix issues where --tabs-from-file doesn't exist or is invalid
Cleanly exit if there are any issues with the given file for --tabs-from-file option. BUG: 367855
-rw-r--r--src/Application.cpp34
-rw-r--r--src/Application.h2
-rw-r--r--src/main.cpp4
3 files changed, 23 insertions, 17 deletions
diff --git a/src/Application.cpp b/src/Application.cpp
index d5dbbd6..e903981 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -108,21 +108,23 @@ int Application::newInstance()
if (m_parser.isSet(QStringLiteral("tabs-from-file"))) {
// create new session(s) as described in file
- processTabsFromFileArgs(window);
- } else {
- // select profile to use
- Profile::Ptr baseProfile = processProfileSelectArgs();
+ if (!processTabsFromFileArgs(window)) {
+ return 0;
+ }
+ }
- // process various command-line options which cause a property of the
- // selected profile to be changed
- Profile::Ptr newProfile = processProfileChangeArgs(baseProfile);
+ // select profile to use
+ Profile::Ptr baseProfile = processProfileSelectArgs();
- // create new session
- Session* session = window->createSession(newProfile, QString());
+ // process various command-line options which cause a property of the
+ // selected profile to be changed
+ Profile::Ptr newProfile = processProfileChangeArgs(baseProfile);
- if (m_parser.isSet(QStringLiteral("noclose"))) {
- session->setAutoClose(false);
- }
+ // create new session
+ Session* session = window->createSession(newProfile, QString());
+
+ if (m_parser.isSet(QStringLiteral("noclose"))) {
+ session->setAutoClose(false);
}
// if the background-mode argument is supplied, start the background
@@ -171,7 +173,7 @@ title: Top this!;; command: top
command: ssh earth
profile: Zsh
*/
-void Application::processTabsFromFileArgs(MainWindow* window)
+bool Application::processTabsFromFileArgs(MainWindow* window)
{
// Open tab configuration file
const QString tabsFileName(m_parser.value(QStringLiteral("tabs-from-file")));
@@ -179,7 +181,7 @@ void Application::processTabsFromFileArgs(MainWindow* window)
if (!tabsFile.open(QFile::ReadOnly)) {
qWarning() << "ERROR: Cannot open tabs file "
<< tabsFileName.toLocal8Bit().data();
- return;
+ return false;
}
unsigned int sessions = 0;
@@ -209,8 +211,10 @@ void Application::processTabsFromFileArgs(MainWindow* window)
if (sessions < 1) {
qWarning() << "No valid lines found in "
<< tabsFileName.toLocal8Bit().data();
- return;
+ return false;
}
+
+ return true;
}
void Application::createTabFromArgs(MainWindow* window,
diff --git a/src/Application.h b/src/Application.h
index 431071e..2f32fda 100644
--- a/src/Application.h
+++ b/src/Application.h
@@ -81,7 +81,7 @@ private:
MainWindow* processWindowArgs(bool &createdNewMainWindow);
Profile::Ptr processProfileSelectArgs();
Profile::Ptr processProfileChangeArgs(Profile::Ptr baseProfile);
- void processTabsFromFileArgs(MainWindow* window);
+ bool processTabsFromFileArgs(MainWindow* window);
void createTabFromArgs(MainWindow* window, const QHash<QString, QString>&);
void finalizeNewMainWindow(MainWindow* window);
diff --git a/src/main.cpp b/src/main.cpp
index 9b3a4f1..c7d797c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -159,7 +159,9 @@ extern "C" int Q_DECL_EXPORT kdemain(int argc, char* argv[])
QObject::connect(&dbusService, &KDBusService::activateRequested, &konsoleApp, &Application::slotActivateRequested);
if (!konsoleApp.newInstance()) {
- // An argument that printed something and mean we should just quit was passed.
+ // Do not finish starting Konsole
+ // 1. An argument was given to just printed info
+ // 2. An invalid situation ocurred
delete app;
return 0;
}