Warn about multiple groups in wxFileConfig instead of asserting

It's not clear whether we handle them correctly, and so it might be
better to refuse input with duplicated groups entirely, but for now at
least avoid asserting when encountering them.
This commit is contained in:
Vadim Zeitlin
2026-07-02 20:48:43 +02:00
parent 5a9bcab361
commit 3ac810a234
2 changed files with 16 additions and 2 deletions
+9 -2
View File
@@ -1514,8 +1514,15 @@ void wxFileConfigGroup::SetLine(wxFileConfigLineList *pLine)
{
// for a normal (i.e. not root) group this method shouldn't be called twice
// unless we are resetting the line
wxASSERT_MSG( !m_pParent || !m_pLine || !pLine,
wxT("changing line for a non-root group?") );
if ( m_pParent )
{
if ( m_pLine && pLine )
{
// It would be nice to give the line numbers but we don't have them
// here easily.
wxLogWarning(_("duplicate group '%s'"), Name());
}
}
m_pLine = pLine;
}
+7
View File
@@ -659,6 +659,13 @@ TEST_CASE_METHOD(LogTestCase, "wxFileConfig::Error", "[fileconfig][error]")
// Check that it's the second quote which is unexpected, not the first one.
checkWarning(R"(foo="x"y)", R"(unexpected " at position 3)");
// Check that a duplicate group is detected as an error.
checkWarning(R"([foo]
bar=1
[foo]
baz=2
)", "duplicate group 'foo'");
}
// This test is disabled by default as it requires the environment variable