Skip to content

Commit

Permalink
fix #277745: reset pointers to Score and ScoreView in Timeline when t…
Browse files Browse the repository at this point in the history
…hey are destroyed
  • Loading branch information
dmitrio95 committed Nov 2, 2018
1 parent c864dda commit d5d1ed8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mscore/timeline.cpp
Expand Up @@ -2230,6 +2230,7 @@ void Timeline::setScore(Score* s)
scene()->clear();

if (_score) {
connect(_score, &QObject::destroyed, this, &Timeline::objectDestroyed, Qt::UniqueConnection);
drawGrid(nstaves(), _score->nmeasures());
changeSelection(SelState::NONE);
row_names->updateLabels(getLabels(), grid_height);
Expand Down Expand Up @@ -2257,12 +2258,25 @@ void Timeline::setScoreView(ScoreView* v)
{
_cv = v;
if (_cv) {
connect(_cv, SIGNAL(sizeChanged()), this, SLOT(updateView()));
connect(_cv, SIGNAL(viewRectChanged()), this, SLOT(updateView()));
connect(_cv, &ScoreView::sizeChanged, this, &Timeline::updateView, Qt::UniqueConnection);
connect(_cv, &ScoreView::viewRectChanged, this, &Timeline::updateView, Qt::UniqueConnection);
connect(_cv, &QObject::destroyed, this, &Timeline::objectDestroyed, Qt::UniqueConnection);
updateView();
}
}

//---------------------------------------------------------
// objectDestroyed
//---------------------------------------------------------

void Timeline::objectDestroyed(QObject* obj)
{
if (_cv == obj)
setScoreView(nullptr);
else if (_score == obj)
setScore(nullptr);
}

//---------------------------------------------------------
// updateView
//---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions mscore/timeline.h
Expand Up @@ -176,6 +176,7 @@ class Timeline : public QGraphicsView {
private slots:
void handle_scroll(int value);
void updateView();
void objectDestroyed(QObject*);

public slots:
void changeSelection(SelState);
Expand Down

0 comments on commit d5d1ed8

Please sign in to comment.