From dd18cc6594b47ee51001b309c62744b1ed8419c7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Jul 2011 13:49:51 +0000 Subject: [PATCH] Reset negatable switches correctly in wxCmdLineParser::Reset(). The "negated" flag of wxCmdLineOption struct was not reset by Reset() so parsing a command line with a negatable option once influenced the result of parsing it the next time because the old value was kept. Do clear it now to allow calling Parse() several times without side effects. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68315 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/cmdline.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/common/cmdline.cpp b/src/common/cmdline.cpp index d32958fb93..4abba86ee8 100644 --- a/src/common/cmdline.cpp +++ b/src/common/cmdline.cpp @@ -106,8 +106,7 @@ struct wxCmdLineOption type = typ; flags = fl; - m_hasVal = false; - m_isNegated = false; + Reset(); } // can't use union easily here, so just store all possible data fields, we @@ -142,12 +141,19 @@ struct wxCmdLineOption { Check(wxCMD_LINE_VAL_DATE); m_dateVal = val; m_hasVal = true; } #endif // wxUSE_DATETIME - void SetHasValue(bool hasValue = true) { m_hasVal = hasValue; } + void SetHasValue() { m_hasVal = true; } bool HasValue() const { return m_hasVal; } void SetNegated() { m_isNegated = true; } bool IsNegated() const { return m_isNegated; } + // Reset to the initial state, called before parsing another command line. + void Reset() + { + m_hasVal = + m_isNegated = false; + } + public: wxCmdLineEntryType kind; wxString shortName, @@ -637,8 +643,7 @@ void wxCmdLineParser::Reset() { for ( size_t i = 0; i < m_data->m_options.GetCount(); i++ ) { - wxCmdLineOption& opt = m_data->m_options[i]; - opt.SetHasValue(false); + m_data->m_options[i].Reset(); } } -- 2.45.2