Skip to content

Commit

Permalink
Fix #304642: inspector update on subtype change
Browse files Browse the repository at this point in the history
- its not enough to only track element-type change when
  to consider if update inspector.
- use Qt deleteLater which is more safe if we have
  signals roaming to old deleted widgets.

Duplicate of musescore#8721
  • Loading branch information
larry authored and Jojo-Schmitz committed Aug 30, 2021
1 parent b799192 commit 9b55161
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Inspector::Inspector(QWidget* parent)
ie = 0;
oe = 0;
oSameTypes = true;
oSameSubtypes = true;
_score = 0;
// retranslate();
setWindowTitle(tr("Inspector"));
Expand Down Expand Up @@ -201,11 +202,13 @@ void Inspector::update(Score* s)
sameSubtypes = false;
}
}
if (oe != element() || oSameTypes != sameTypes || (sameTypes && !sameSubtypes)) {
delete ie;
if (oe != element() ||
(oSameTypes != sameTypes) ||
(oSameSubtypes != sameSubtypes)) {
ie = 0;
oe = element();
oSameTypes = sameTypes;
oSameSubtypes = sameSubtypes;
if (!element())
ie = new InspectorEmpty(this);
else if (!sameTypes)
Expand Down Expand Up @@ -324,6 +327,7 @@ void Inspector::update(Score* s)
else
ie = new InspectorBreak(this);
#endif
//FIX: it looks as we might end up with ie = 0
break;
case ElementType::BEND:
ie = new InspectorBend(this);
Expand Down Expand Up @@ -399,8 +403,13 @@ void Inspector::update(Score* s)
break;
}
}
Q_ASSERT(ie);
connect(ie, &InspectorBase::elementChanged, this, QOverload<>::of(&Inspector::update), Qt::QueuedConnection);
sa->setWidget(ie); // will destroy previous set widget
if (sa->widget()) { // If old inspector exist
QWidget *q = sa->takeWidget();
q->deleteLater();
}
sa->setWidget(ie); // will destroy previous set widget, unless takeWidget() call

//focus policies were set by hand in each inspector_*.ui. this code just helps keeping them like they are
//also fixes mac problem. on Mac Qt::TabFocus doesn't work, but Qt::StrongFocus works
Expand Down
1 change: 1 addition & 0 deletions mscore/inspector/inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ class Inspector : public QDockWidget {
// within the inspector itself
Element* oe;
bool oSameTypes;
bool oSameSubtypes;

public slots:
void update();
Expand Down

0 comments on commit 9b55161

Please sign in to comment.