summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-01-15 17:00:28 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-16 18:52:28 +0100
commit3a2631391914e002769d0e3f6a934d241fa1d389 (patch)
tree248162eb0d65a84a1274c2562c477d8f1c1cd1e1 /src
parent3575ebfd9ddcef90aee107ce76ec181fa9a10735 (diff)
Make QCommandLineParser not crash if passed a bad QCommandLineOption
This otherwise crashed: QCommandLineOotion opt("with=equals"); parser.isSet(opt); Can't write a unit test because it produces a warning. Change-Id: Ifc67f20bb4b16b96d93dffbe4e82e6cc8a17584d Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index db4c2961f0..c860b4d155 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -720,7 +720,8 @@ QStringList QCommandLineParser::values(const QString &optionName) const
*/
bool QCommandLineParser::isSet(const QCommandLineOption &option) const
{
- return isSet(option.names().first());
+ // option.names() might be empty if the constructor failed
+ return !option.names().isEmpty() && isSet(option.names().first());
}
/*!