Skip to content

Commit 88e59d1

Browse files
committed
fixed crash on move selection
1 parent d26b912 commit 88e59d1

9 files changed

Lines changed: 29 additions & 6 deletions

File tree

.github/workflows/build_macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Build: macOS'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66
inputs:
77
build_mode:

.github/workflows/build_windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Build: Windows'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66
inputs:
77
platforms:

.github/workflows/build_without_qt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Build: Without Qt'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66

77
jobs:

.github/workflows/check_codestyle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Check: Codestyle'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66

77
jobs:

.github/workflows/check_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Check: Unit Tests (utest)'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66
inputs:
77
code_coverage:

.github/workflows/check_visual_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: 'Check: Visual Tests (vtest)'
22

33
on:
4-
pull_request:
4+
#pull_request:
55
workflow_dispatch:
66
inputs:
77
use_qt69:

src/engraving/dom/engravingitem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,19 +1672,27 @@ bool EngravingItem::isSystemObjectBelowBottomStaff() const
16721672

16731673
EngravingItem* EngravingItem::findAncestor(ElementType t)
16741674
{
1675+
LOGDA() << "this: " << this;
16751676
EngravingItem* e = this;
16761677
while (e && e->type() != t) {
1678+
e->increment();
16771679
e = e->parentItem();
1680+
LOGDA() << "parentItem: " << e;
16781681
}
1682+
LOGDA() << "return parentItem: " << e;
16791683
return e;
16801684
}
16811685

16821686
const EngravingItem* EngravingItem::findAncestor(ElementType t) const
16831687
{
1688+
LOGDA() << "this: " << this;
16841689
const EngravingItem* e = this;
16851690
while (e && e->type() != t) {
1691+
e->increment();
16861692
e = e->parentItem();
1693+
LOGDA() << "parentItem: " << e;
16871694
}
1695+
LOGDA() << "return parentItem: " << e;
16881696
return e;
16891697
}
16901698

src/engraving/dom/engravingitem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class EngravingItem : public EngravingObject
171171

172172
void deleteLater();
173173

174+
mutable int m_increment = 0;
175+
void increment() const { m_increment++; }
176+
174177
EngravingItem* parentItem(bool explicitParent = true) const;
175178
EngravingItemList childrenItems(bool all = false) const;
176179

src/notation/internal/notationinteraction.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,14 +4083,26 @@ void NotationInteraction::moveElementSelection(MoveDirection d)
40834083

40844084
// VBoxes are not included in horizontal layouts - skip over them (and their contents) when moving selections...
40854085
const auto nextNonVBox = [this, isLeftDirection](EngravingItem* currElem) -> EngravingItem* {
4086+
LOGDA() << "currElem: " << currElem;
4087+
4088+
IF_ASSERT_FAILED(currElem) {
4089+
return nullptr;
4090+
}
4091+
40864092
while (const EngravingItem* vBox = currElem->findAncestor(ElementType::VBOX)) {
4093+
LOGDA() << "vBox: " << vBox;
40874094
currElem = isLeftDirection ? toVBox(vBox)->prevMM() : toVBox(vBox)->nextMM();
40884095
if (currElem && currElem->isMeasure()) {
40894096
const ChordRest* cr = score()->selection().currentCR();
40904097
const staff_idx_t si = cr ? cr->staffIdx() : 0;
40914098
Measure* mb = toMeasure(currElem);
40924099
currElem = isLeftDirection ? mb->prevElementStaff(si, currElem) : mb->nextElementStaff(si, currElem);
40934100
}
4101+
4102+
if (!currElem) {
4103+
break;
4104+
}
4105+
LOGDA() << "end of while";
40944106
}
40954107
return currElem;
40964108
};

0 commit comments

Comments
 (0)