Commit 2aa51bc3 authored by schultezub's avatar schultezub

* fixed various memory leaks

 * added AbstractProperty::(de)init and HasPropertyCollection::(de)initAllProperties

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@213 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent b7aa2254
......@@ -17,7 +17,7 @@ namespace TUMVis {
}
IntPropertyWidget::~IntPropertyWidget() {
static_cast<IntProperty*>(_property)->s_minMaxChanged.disconnect(this);
}
void IntPropertyWidget::updateWidgetFromProperty() {
......
......@@ -17,7 +17,7 @@ namespace TUMVis {
, _spinDomainLeft(0)
, _spinDomainRight(0)
, _btnEditTF(0)
,_dockWidget(0)
, _dockWidget(0)
, _editor(0)
{
_widget = new QWidget(this);
......@@ -54,7 +54,6 @@ namespace TUMVis {
TransferFunctionPropertyWidget::~TransferFunctionPropertyWidget() {
delete _dockWidget;
delete _editor;
}
void TransferFunctionPropertyWidget::updateWidgetFromProperty() {
......
......@@ -48,8 +48,6 @@ namespace TUMVis {
for (std::vector<AbstractPipeline*>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
delete *it;
}
// TODO: _mainWindow is a Qt pointer and does not need to be deleted - right?
}
void TumVisApplication::init() {
......@@ -113,6 +111,8 @@ namespace TUMVis {
tgt::QtContextManager::deinit();
tgt::deinit();
delete _mainWindow;
_initialized = false;
}
......
......@@ -130,6 +130,13 @@ namespace TUMVis {
void TumVisPainter::deinit() {
ShdrMgr.dispose(_copyShader);
if (_pipeline != 0) {
_pipeline->s_renderTargetChanged.disconnect(this);
if (getCanvas()->getEventHandler() != 0)
getCanvas()->getEventHandler()->removeListener(_pipeline);
_pipeline = 0;
}
}
void TumVisPainter::setPipeline(VisualizationPipeline* pipeline) {
......
......@@ -15,18 +15,22 @@ namespace TUMVis {
}
void AbstractPipeline::init() {
initAllProperties();
// initialize all processors:
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
(*it)->init();
}
catch (tgt::Exception& e) {
LERROR("Caught Exception during initialization of processor: " << e.what());
}
}
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
(*it)->init();
}
catch (tgt::Exception& e) {
LERROR("Caught Exception during initialization of processor: " << e.what());
}
}
}
void AbstractPipeline::deinit() {
deinitAllProperties();
// deinitialize all processors:
for (std::vector<AbstractProcessor*>::iterator it = _processors.begin(); it != _processors.end(); ++it) {
try {
......
......@@ -28,9 +28,11 @@ namespace TUMVis {
}
void AbstractProcessor::init() {
initAllProperties();
}
void AbstractProcessor::deinit() {
deinitAllProperties();
}
......
......@@ -59,7 +59,7 @@ namespace TUMVis {
virtual void init();
/**
* Deinitializes this processors.
* Deinitializes this processor.
* \note When overwriting this method, make sure to call the base class version first.
*/
virtual void deinit();
......
......@@ -55,4 +55,12 @@ namespace TUMVis {
_inUse = false;
}
void AbstractProperty::init() {
}
void AbstractProperty::deinit() {
}
}
......@@ -32,6 +32,18 @@ namespace TUMVis {
virtual ~AbstractProperty();
/**
* Initializes the property.
* Everything that requires a valid OpenGL context or is otherwise expensive gets in here.
*/
virtual void init();
/**
* Deinitializes this property.
* Everything that requires a valid OpenGL context gets in here instead into the dtor.
*/
virtual void deinit();
/**
* Returns the property name.
* \return _name
......
......@@ -74,4 +74,16 @@ namespace TUMVis {
}
}
void HasPropertyCollection::initAllProperties() {
for (PropertyCollection::iterator it = _properties.begin(); it != _properties.end(); ++it) {
(*it)->init();
}
}
void HasPropertyCollection::deinitAllProperties() {
for (PropertyCollection::iterator it = _properties.begin(); it != _properties.end(); ++it) {
(*it)->deinit();
}
}
}
\ No newline at end of file
......@@ -71,6 +71,16 @@ namespace TUMVis {
*/
virtual void unlockAllProperties();
/**
* Initializes all properties.
*/
virtual void initAllProperties();
/**
* Deinitializes all properties.
*/
virtual void deinitAllProperties();
/**
* Slot getting called when one of the observed properties changed and notifies its observers.
* \param prop Property that emitted the signal
......
......@@ -13,7 +13,8 @@ namespace TUMVis {
}
TransferFunctionProperty::~TransferFunctionProperty() {
_transferFunction->s_changed.disconnect(this);
delete _transferFunction;
}
AbstractTransferFunction* TransferFunctionProperty::getTF() {
......@@ -24,4 +25,8 @@ namespace TUMVis {
s_changed(this);
}
void TransferFunctionProperty::deinit() {
_transferFunction->deinit();
}
}
......@@ -22,6 +22,8 @@ namespace TUMVis {
**/
virtual ~TransferFunctionProperty();
/// \overload
virtual void deinit();
AbstractTransferFunction* getTF();
......
......@@ -32,10 +32,12 @@ namespace TUMVis {
}
void SliceExtractor::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/sliceextractor.frag", "", false);
}
void SliceExtractor::deinit() {
VisualizationProcessor::deinit();
ShdrMgr.dispose(_shader);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment