Skip to content

Commit dc17d47

Browse files
authored
Fixed hang if there were lots of unused ODF entries #1918 (#2045)
1 parent 7b1ac36 commit dc17d47

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Fixed hang if there were lots of unused ODF entries https://github.com/GrandOrgue/grandorgue/issues/1918
12
# 3.15.3 (2024-11-23)
23
- Fixed crash of reference pipes with the "--justgui" option https://github.com/GrandOrgue/grandorgue/issues/2019
34
- Fixed crash on attempt of loading an organ if it's files did not exist https://github.com/GrandOrgue/grandorgue/issues/1990

src/core/config/GOConfigReaderDB.cpp

+20-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2006 Milan Digital Audio LLC
3-
* Copyright 2009-2023 GrandOrgue contributors (see AUTHORS)
3+
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
44
* License GPL-2.0 or later
55
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
66
*/
@@ -12,30 +12,36 @@
1212

1313
#include "config/GOConfigFileReader.h"
1414

15+
static constexpr unsigned UNUSED_REPORT_LIMIT = 3000;
16+
1517
GOConfigReaderDB::GOConfigReaderDB(bool case_sensitive)
1618
: m_CaseSensitive(case_sensitive), m_ODF(1000), m_ODF_LC(1000), m_CMB(100) {}
1719

1820
GOConfigReaderDB::~GOConfigReaderDB() {}
1921

2022
void GOConfigReaderDB::ReportUnused() {
21-
for (GOBoolHashMap::iterator i = m_CMBUsed.begin(); i != m_CMBUsed.end();
22-
i++) {
23-
if (!i->second) {
24-
wxLogWarning(_("Unused CMB entry '%s'"), i->first.c_str());
23+
for (const auto &pair : m_CMBUsed) {
24+
if (!pair.second) {
25+
wxLogWarning(_("Unused CMB entry '%s'"), pair.first);
2526
}
2627
}
28+
2729
bool warn_old = false;
28-
for (GOBoolHashMap::iterator i = m_ODFUsed.begin(); i != m_ODFUsed.end();
29-
i++) {
30-
if (!i->second) {
31-
if (i->first.StartsWith(wxT("_"))) {
32-
if (!warn_old) {
30+
unsigned unusedCnt = 0;
31+
32+
for (const auto &pair : m_ODFUsed) {
33+
if (!pair.second) {
34+
if (++unusedCnt > UNUSED_REPORT_LIMIT) {
35+
wxLogWarning(
36+
_("More than %u unused ODF entries detected"), UNUSED_REPORT_LIMIT);
37+
break;
38+
}
39+
if (pair.first.StartsWith(wxT("_"))) {
40+
if (!warn_old)
3341
wxLogWarning(_("Old GO 0.2 styled setting in ODF"));
34-
}
3542
warn_old = true;
36-
} else {
37-
wxLogWarning(_("Unused ODF entry '%s'"), i->first.c_str());
38-
}
43+
} else
44+
wxLogWarning(_("Unused ODF entry '%s'"), pair.first);
3945
}
4046
}
4147
}

0 commit comments

Comments
 (0)