Import 2017-06-07 23:51:09: master c1fdaf73

Author Committer Branch Timestamp Parent
jcfr jcfr master 2015-07-17 01:00:59 master 1a25316a
Changeset

BUG: Fix memory leaks in SubjectHierarchy Register and Segment plugins

Since QMenu constructor does not take a QObject as a parent, this commit
introduces a QSharedPointer to manage the menu instance.

This commit fixes the error(s) reported below by valgrind memcheck tool.

Valgrind was used on Ubuntu 14.04 against a Debug build of Slicer. It was
exected doing the following:
(1) Start a terminal with the appropriate environment: ./Slicer --gnome-terminal
(2) Start Slicer using valgrind: valgrind --log-file=2015-07-16-Slicer-memcheck.txt --tool=memcheck --leak-check=yes ./bin/SlicerApp-real --disable-python --disable-cli-modules
(3) Exit Slicer and inspect valgrind log file

Valgrind error:

==29339== 1,160 (40 direct, 1,120 indirect) bytes in 1 blocks are definitely lost in loss record 2,294 of 2,448
==29339== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29339== by 0x10550A4D9: qSlicerSubjectHierarchySegmentPluginPrivate::init() (qSlicerSubjectHierarchySegmentPlugin.cxx:114)
==29339== by 0x10550A3E7: qSlicerSubjectHierarchySegmentPlugin::qSlicerSubjectHierarchySegmentPlugin(QObject) (qSlicerSubjectHierarchySegmentPlugin.cxx:103)
==29339== by 0x1054F1217: qSlicerSubjectHierarchyPluginLogic::registerCorePlugins() (qSlicerSubjectHierarchyPluginLogic.cxx:139)
==29339== by 0x1054F0DFD: qSlicerSubjectHierarchyPluginLogic::qSlicerSubjectHierarchyPluginLogic(QWidget
) (qSlicerSubjectHierarchyPluginLogic.cxx:117)
==29339== by 0x1080E2F5C: qSlicerSubjectHierarchyModule::createLogic() (qSlicerSubjectHierarchyModule.cxx:137)
==29339== by 0x8E715C1: qSlicerAbstractCoreModule::logic() (qSlicerAbstractCoreModule.cxx:280)
==29339== by 0x8E70BAD: qSlicerAbstractCoreModule::initialize(vtkSlicerApplicationLogic*) (qSlicerAbstractCoreModule.cxx:99)
==29339== by 0x8EA2A19: qSlicerModuleFactoryManager::loadModule(QString const&, QString const&) (qSlicerModuleFactoryManager.cxx:170)
==29339== by 0x8EA2586: qSlicerModuleFactoryManager::loadModule(QString const&) (qSlicerModuleFactoryManager.cxx:110)
==29339== by 0x40672A: (anonymous namespace)::SlicerAppMain(int, char**) (Main.cxx:193)
==29339== by 0x406D30: main (Main.cxx:254)

==29339==
==29339== 1,176 (40 direct, 1,136 indirect) bytes in 1 blocks are definitely lost in loss record 2,296 of 2,448
==29339== at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29339== by 0x105507073: qSlicerSubjectHierarchyRegisterPluginPrivate::init() (qSlicerSubjectHierarchyRegisterPlugin.cxx:120)
==29339== by 0x105506EC1: qSlicerSubjectHierarchyRegisterPlugin::qSlicerSubjectHierarchyRegisterPlugin(QObject) (qSlicerSubjectHierarchyRegisterPlugin.cxx:104)
==29339== by 0x1054F11ED: qSlicerSubjectHierarchyPluginLogic::registerCorePlugins() (qSlicerSubjectHierarchyPluginLogic.cxx:137)
==29339== by 0x1054F0DFD: qSlicerSubjectHierarchyPluginLogic::qSlicerSubjectHierarchyPluginLogic(QWidget
) (qSlicerSubjectHierarchyPluginLogic.cxx:117)
==29339== by 0x1080E2F5C: qSlicerSubjectHierarchyModule::createLogic() (qSlicerSubjectHierarchyModule.cxx:137)
==29339== by 0x8E715C1: qSlicerAbstractCoreModule::logic() (qSlicerAbstractCoreModule.cxx:280)
==29339== by 0x8E70BAD: qSlicerAbstractCoreModule::initialize(vtkSlicerApplicationLogic*) (qSlicerAbstractCoreModule.cxx:99)
==29339== by 0x8EA2A19: qSlicerModuleFactoryManager::loadModule(QString const&, QString const&) (qSlicerModuleFactoryManager.cxx:170)
==29339== by 0x8EA2586: qSlicerModuleFactoryManager::loadModule(QString const&) (qSlicerModuleFactoryManager.cxx:110)
==29339== by 0x40672A: (anonymous namespace)::SlicerAppMain(int, char**) (Main.cxx:193)
==29339== by 0x406D30: main (Main.cxx:254)

git-svn-id: http://svn.slicer.org/Slicer4/trunk@24445 3bd1e089-480b-0410-8dfb-8563597acbee

mod - Modules/Loadable/SubjectHierarchy/Widgets/qSlicerSubjectHierarchyRegisterPlugin.cxx Diff File
mod - Modules/Loadable/SubjectHierarchy/Widgets/qSlicerSubjectHierarchySegmentPlugin.cxx Diff File