Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Close] 4D+3D data in view crash at app closing --dev #1175

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ class medAbstractParameterLPrivate
public:
QString name;
QList <QWidget *> internWidget;
QLabel *label;
QPointer<QLabel> label;
QString toolTip;

bool hide;

~medAbstractParameterLPrivate() {delete label;}
};

medAbstractParameterL::medAbstractParameterL(QString name, QObject *parent):
Expand Down
8 changes: 7 additions & 1 deletion src/layers/medCore/legacy/parameters/medDoubleParameterL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ QLabel* medDoubleParameterL::getValueLabel()
d->valueLabel->setText(QString::number(m_value, 'g', 2));

this->addToInternWidgets(d->valueLabel);
connect(d->valueLabel, SIGNAL(destroyed()), this, SLOT(removeInternSlider()));
connect(d->valueLabel, SIGNAL(destroyed()), this, SLOT(removeInternLabel()));
}

return d->valueLabel;
Expand All @@ -249,6 +249,12 @@ void medDoubleParameterL::removeInternSlider()
d->slider = nullptr;
}

void medDoubleParameterL::removeInternLabel()
{
this->removeFromInternWidgets(d->valueLabel);
d->valueLabel = nullptr;
}

int medDoubleParameterL::convertToInt(double value)
{
return static_cast<int>((value-d->min)/d->step);
Expand Down
1 change: 1 addition & 0 deletions src/layers/medCore/legacy/parameters/medDoubleParameterL.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public slots:
private slots:
void removeInternSpinBox();
void removeInternSlider();
void removeInternLabel();

void setSliderIntValue(int value);

Expand Down
9 changes: 5 additions & 4 deletions src/layers/medCore/legacy/parameters/medParameterPoolL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ void medParameterPoolL::remove(medAbstractParameterL* parameter)

disconnectParam(parameter);

QHashIterator<QString, medAbstractParameterL*> it(d->pool);

QMutableHashIterator<QString, medAbstractParameterL*> it(d->pool);
while(it.hasNext())
{
it.next();
if(it.value() == parameter)
d->pool.remove(it.key(), it.value());
if(it.value() && it.value() == parameter)
{
it.remove();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ medTimeLineParameterL::medTimeLineParameterL(QString name, QObject *parent):

medTimeLineParameterL::~medTimeLineParameterL()
{
emit aboutToBeDestroyed();
delete d;
}

Expand Down Expand Up @@ -286,7 +287,6 @@ void medTimeLineParameterL::setDuration(const double& timeDuration)
d->timeBetweenFrames = 0;

d->timeLine->setDuration(timeDuration*1000);

}

void medTimeLineParameterL::setFrame(int frame)
Expand Down
2 changes: 2 additions & 0 deletions src/layers/medCore/legacy/parameters/medTimeLineParameterL.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public slots:
void playing(bool isPlaying);
void timeChanged(double time);

void aboutToBeDestroyed();

private slots:
void updateTime(double time);
void updateFrameLabel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ medAbstractImageViewNavigator::medAbstractImageViewNavigator(medAbstractView *pa
}

connect(this, SIGNAL(currentTimeChanged(double)), d->view, SIGNAL(currentTimeChanged(double)));
connect(d->view, SIGNAL(layerAdded(uint)), this, SLOT(updateTimeLineParameter()));
connect(d->view, SIGNAL(layerRemoved(uint)), this, SLOT(updateTimeLineParameter()));
connect(d->view, SIGNAL(currentLayerChanged()), this, SLOT(updateTimeLineParameter()), Qt::UniqueConnection);
}

medAbstractImageViewNavigator::~medAbstractImageViewNavigator()
{
delete d->timeLineParameter;
delete d;
}

Expand Down Expand Up @@ -98,36 +98,42 @@ void medAbstractImageViewNavigator::setCurrentTime (const double &time)

void medAbstractImageViewNavigator::updateTimeLineParameter()
{
bool viewHasTemporalData = false;

double sequenceDuration = 0;
double sequenceFrameRate = 0;
for(medDataIndex index : d->view->dataList())
if (d->timeLineParameter)
{
medAbstractData *data = medDataManager::instance()->retrieveData(index);
if (!data)
continue;
bool viewHasTemporalData = false;

double sequenceDuration = 0;
double sequenceFrameRate = 0;

if(data->hasMetaData("SequenceDuration") && data->hasMetaData("SequenceFrameRate"))
for(medDataIndex index : d->view->dataList())
{
double sd = data->metadata("SequenceDuration").toDouble();
sequenceDuration = (sequenceDuration < sd) ? sd : sequenceDuration;
medAbstractData *data = medDataManager::instance()->retrieveData(index);
if (!data)
continue;

double sf = data->metadata("SequenceFrameRate").toDouble();
sequenceFrameRate = (sequenceFrameRate < sf) ? sf : sequenceFrameRate;
if(data->hasMetaData("SequenceDuration") && data->hasMetaData("SequenceFrameRate"))
{
double sd = data->metadata("SequenceDuration").toDouble();
sequenceDuration = (sequenceDuration < sd) ? sd : sequenceDuration;

viewHasTemporalData = true;
double sf = data->metadata("SequenceFrameRate").toDouble();
sequenceFrameRate = (sequenceFrameRate < sf) ? sf : sequenceFrameRate;

viewHasTemporalData = true;
}
}
if(viewHasTemporalData)
{
unsigned int numFrames = (unsigned int)round(sequenceDuration * sequenceFrameRate);
d->timeLineParameter->setNumberOfFrame(numFrames);
d->timeLineParameter->setDuration(sequenceDuration);
d->timeLineParameter->show();
}
else
{
d->timeLineParameter->hide();
}
}
if(viewHasTemporalData)
{
unsigned int numFrames = (unsigned int)round(sequenceDuration * sequenceFrameRate);
d->timeLineParameter->setNumberOfFrame(numFrames);
d->timeLineParameter->setDuration(sequenceDuration);
d->timeLineParameter->show();
}
else
d->timeLineParameter->hide();
}

void medAbstractImageViewNavigator::toXMLNode(QDomDocument *doc, QDomElement *currentNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ medAbstractNavigator::medAbstractNavigator(medAbstractView *parent):

medAbstractNavigator::~medAbstractNavigator()
{
delete d->toolBoxWidget;
delete d;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ medVtkViewItkDataImageNavigator::medVtkViewItkDataImageNavigator(medAbstractView

medVtkViewItkDataImageNavigator::~medVtkViewItkDataImageNavigator()
{
for(medAbstractParameterL *parameter : d->parameters)
{
delete parameter->getLabel();
}

delete d;
}

Expand Down