Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
e8090947
Commit
e8090947
authored
Nov 21, 2011
by
Mario Hlawitschka
Browse files
[FIX
#107
] fixed a memory leak where widgets have not been deleted properly
parent
fb3b7787
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
src/qt4gui/qt4/controlPanel/WQtControlPanel.cpp
src/qt4gui/qt4/controlPanel/WQtControlPanel.cpp
+17
-6
src/qt4gui/qt4/controlPanel/WQtControlPanel.h
src/qt4gui/qt4/controlPanel/WQtControlPanel.h
+6
-0
No files found.
src/qt4gui/qt4/controlPanel/WQtControlPanel.cpp
View file @
e8090947
...
...
@@ -668,8 +668,7 @@ void WQtControlPanel::selectTreeItem()
if
(
m_moduleTreeWidget
->
selectedItems
().
size
()
!=
0
)
{
// TODO(schurade): qt doc says clear() doesn't delete tabs so this is possibly a memory leak
m_tabWidget
->
clear
();
clearAndDeleteTabs
();
// disable delete action for tree items that have children.
if
(
m_moduleTreeWidget
->
selectedItems
().
at
(
0
)
->
childCount
()
!=
0
)
...
...
@@ -755,8 +754,7 @@ void WQtControlPanel::selectTreeItem()
void
WQtControlPanel
::
selectRoiTreeItem
()
{
// TODO(schurade): qt doc says clear() doesn't delete tabs so this is possibly a memory leak
m_tabWidget
->
clear
();
clearAndDeleteTabs
();
// Make compatibles toolbar empty
{
...
...
@@ -833,13 +831,13 @@ void WQtControlPanel::selectDataModule( boost::shared_ptr< WDataSet > dataSet )
void
WQtControlPanel
::
selectDataModule
(
osg
::
ref_ptr
<
WGETexture3D
>
texture
)
{
m_tabWidget
->
clear
();
clearAndDeleteTabs
();
buildPropTab
(
texture
->
getProperties
(),
texture
->
getInformationProperties
()
);
}
void
WQtControlPanel
::
setNewActiveModule
(
boost
::
shared_ptr
<
WModule
>
module
)
{
m_tabWidget
->
clear
();
clearAndDeleteTabs
();
// NOTE: this handles null pointers properly.
createCompatibleButtons
(
module
);
...
...
@@ -1201,3 +1199,16 @@ QAction* WQtControlPanel::getMissingModuleAction() const
{
return
m_missingModuleAction
;
}
void
WQtControlPanel
::
clearAndDeleteTabs
()
{
m_tabWidget
->
setDisabled
(
true
);
QWidget
*
widget
;
while
((
widget
=
m_tabWidget
->
widget
(
0
)
))
{
m_tabWidget
->
removeTab
(
0
);
delete
widget
;
}
m_tabWidget
->
setEnabled
(
true
);
}
src/qt4gui/qt4/controlPanel/WQtControlPanel.h
View file @
e8090947
...
...
@@ -264,6 +264,12 @@ protected:
*/
std
::
list
<
WQtTreeItem
*
>
findItemsByModule
(
boost
::
shared_ptr
<
WModule
>
module
);
/**
* As QTabWidget::clear() does not delete tabs, we have to manage that ourselves.
* So this function clears all tabs and deletes the data as well.
*/
void
clearAndDeleteTabs
();
private:
WQtTreeWidget
*
m_moduleTreeWidget
;
//!< pointer to the tree widget
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment