From 3a2631391914e002769d0e3f6a934d241fa1d389 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 15 Jan 2014 17:00:28 -0800 Subject: 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 --- src/corelib/tools/qcommandlineparser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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()); } /*! -- cgit v1.2.3