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

fix #277745: reset pointers to Score and ScoreView in Timeline when they are destroyed #4092

Merged
merged 1 commit into from
Nov 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions mscore/timeline.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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