QCommandLineParser: pluck some low-hanging fruit re: exception safety
authorMarc Mutz <marc.mutz@kdab.com>
Sat, 5 Oct 2013 01:20:56 +0000 (03:20 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 6 Dec 2013 07:44:31 +0000 (08:44 +0100)
commit03affacaa3d5530e96f869a8a6e900ca5e714918
tree3e060f7b8bac0edd9f210c77d35d49925a868a96
parent689152e7c1c6b0e851937a20de96c99aa7a7ea2b
QCommandLineParser: pluck some low-hanging fruit re: exception safety

Make
  QCommandLineParser::add{Help,Version}Option()
  QCommandLineOption::setDefaultValue()
  QCommandLineOptionPrivate::setNames()
have transaction semantics: either they succeed, or they change nothing.
It's trivial to provide this guarantee, so do it.

Add a test for the surprising property that setDefaultValue("") resets
defaultValues() to an empty QStringList instead of one that contains
the empty string.

Change-Id: I61623019de3c7d2e52c24f42cc2e23ec5fddc4da
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/tools/qcommandlineoption.cpp
src/corelib/tools/qcommandlineparser.cpp
tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp