diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-01-15 17:00:28 -0800 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-16 18:52:28 +0100 |
commit | 3a2631391914e002769d0e3f6a934d241fa1d389 (patch) | |
tree | 248162eb0d65a84a1274c2562c477d8f1c1cd1e1 /src/corelib/tools/qcommandlineparser.cpp | |
parent | 3575ebfd9ddcef90aee107ce76ec181fa9a10735 (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/corelib/tools/qcommandlineparser.cpp')
-rw-r--r-- | src/corelib/tools/qcommandlineparser.cpp | 3 |
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()); } /*! |