aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/src/commandline.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/src/commandline.cpp b/src/src/commandline.cpp
index 4ff408e..46f9be0 100644
--- a/src/src/commandline.cpp
+++ b/src/src/commandline.cpp
@@ -13,6 +13,7 @@
#include <QFile>
#include <QSettings>
#include <QTextStream>
+#include <boost/optional/optional_io.hpp>
namespace cl
{
@@ -233,8 +234,12 @@ std::optional<int> CommandLine::runEarly()
std::optional<int> CommandLine::runPostApplication(MOApplication& a)
{
- // handle -i with no arguments
- if (m_vm.contains("instance") && m_vm["instance"].as<std::string>().empty()) {
+ const auto instanceArg = m_vm.find("instance");
+ if (instanceArg != m_vm.end() &&
+ !instanceArg->second.as<boost::optional<std::string>>().has_value()) {
+ // handle -i with no arguments (distinct from -i "", which will launch the
+ // portable instance if it exists, hence the use of boost::optional).
+ // Upstream PR #2341.
env::Console const c;
if (auto i = InstanceManager::singleton().currentInstance()) {
@@ -326,7 +331,9 @@ void CommandLine::createOptions()
("logs", "duplicates the logs to stdout")
- ("instance,i", po::value<std::string>()->implicit_value(""),
+ ("instance,i",
+ po::value<boost::optional<std::string>>()->implicit_value(
+ boost::none),
"use the given instance (defaults to last used)")
("profile,p", po::value<std::string>(),
@@ -414,8 +421,15 @@ std::optional<QString> CommandLine::instance() const
if (m_shortcut.isValid() && m_shortcut.hasInstance()) {
return m_shortcut.instanceName();
- } else if (m_vm.contains("instance")) {
- return QString::fromStdString(m_vm["instance"].as<std::string>());
+ } else {
+ const auto instanceArg = m_vm.find("instance");
+ if (instanceArg != m_vm.end()) {
+ const auto& instanceVal =
+ instanceArg->second.as<boost::optional<std::string>>();
+ if (instanceVal.has_value()) {
+ return QString::fromStdString(instanceVal.value());
+ }
+ }
}
return {};