mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-26 18:18:26 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user