Skip to content

Commit

Permalink
fix: Fix memory leaks in Displayer and RecognitionMenu
Browse files Browse the repository at this point in the history
Fix two memory management issues:
- Add missing deletion of m_imageItem in Displayer::setSources
- Set proper parent for PSM menu to ensure proper cleanup

These changes prevent memory leaks and ensure proper resource cleanup when
the application exits or when components are destroyed.
  • Loading branch information
Kakueeen authored and manisandro committed Dec 9, 2024
1 parent b794fd5 commit 69cf683
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions qt/src/Displayer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ bool Displayer::setSources(QList<Source*> sources) {
m_renderTimer.stop();
if(m_imageItem) {
m_scene->removeItem(m_imageItem);
delete m_imageItem;
}
m_currentSource = nullptr;
qDeleteAll(m_sourceRenderers);
Expand Down
2 changes: 1 addition & 1 deletion qt/src/RecognitionMenu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void RecognitionMenu::rebuild() {

// Add PSM items
addSeparator();
QMenu* psmMenu = new QMenu();
QMenu* psmMenu = new QMenu(this);
int activePsm = ConfigSettings::get<VarSetting<int>>("psm")->getValue();

struct PsmEntry {
Expand Down

0 comments on commit 69cf683

Please sign in to comment.