Skip to content

Commit

Permalink
Fixed hang if there were lots of unused ODF entries GrandOrgue#1918 (G…
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 authored Nov 28, 2024
1 parent 7b1ac36 commit dc17d47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed hang if there were lots of unused ODF entries https://github.com/GrandOrgue/grandorgue/issues/1918
# 3.15.3 (2024-11-23)
- Fixed crash of reference pipes with the "--justgui" option https://github.com/GrandOrgue/grandorgue/issues/2019
- Fixed crash on attempt of loading an organ if it's files did not exist https://github.com/GrandOrgue/grandorgue/issues/1990
Expand Down
34 changes: 20 additions & 14 deletions src/core/config/GOConfigReaderDB.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2023 GrandOrgue contributors (see AUTHORS)
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/
Expand All @@ -12,30 +12,36 @@

#include "config/GOConfigFileReader.h"

static constexpr unsigned UNUSED_REPORT_LIMIT = 3000;

GOConfigReaderDB::GOConfigReaderDB(bool case_sensitive)
: m_CaseSensitive(case_sensitive), m_ODF(1000), m_ODF_LC(1000), m_CMB(100) {}

GOConfigReaderDB::~GOConfigReaderDB() {}

void GOConfigReaderDB::ReportUnused() {
for (GOBoolHashMap::iterator i = m_CMBUsed.begin(); i != m_CMBUsed.end();
i++) {
if (!i->second) {
wxLogWarning(_("Unused CMB entry '%s'"), i->first.c_str());
for (const auto &pair : m_CMBUsed) {
if (!pair.second) {
wxLogWarning(_("Unused CMB entry '%s'"), pair.first);
}
}

bool warn_old = false;
for (GOBoolHashMap::iterator i = m_ODFUsed.begin(); i != m_ODFUsed.end();
i++) {
if (!i->second) {
if (i->first.StartsWith(wxT("_"))) {
if (!warn_old) {
unsigned unusedCnt = 0;

for (const auto &pair : m_ODFUsed) {
if (!pair.second) {
if (++unusedCnt > UNUSED_REPORT_LIMIT) {
wxLogWarning(
_("More than %u unused ODF entries detected"), UNUSED_REPORT_LIMIT);
break;
}
if (pair.first.StartsWith(wxT("_"))) {
if (!warn_old)
wxLogWarning(_("Old GO 0.2 styled setting in ODF"));
}
warn_old = true;
} else {
wxLogWarning(_("Unused ODF entry '%s'"), i->first.c_str());
}
} else
wxLogWarning(_("Unused ODF entry '%s'"), pair.first);
}
}
}
Expand Down

0 comments on commit dc17d47

Please sign in to comment.