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>
This commit is contained in:
Thiago Macieira 2014-01-15 17:00:28 -08:00 committed by The Qt Project
parent 3575ebfd9d
commit 3a26313919

View File

@ -720,7 +720,8 @@ QStringList QCommandLineParser::values(const QString &optionName) const
*/ */
bool QCommandLineParser::isSet(const QCommandLineOption &option) 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());
} }
/*! /*!