Skip to content

Commit 180902b

Browse files
committed
Fix #31724: Double notehead when adding to Laissez Vibrer note
When adding a new note, to a note with a Laissez Vibrer, a double notehead is wrongfully created. This fix changes the put_note action by excluding notes with a Laissez Vibrer tie, when the function checks whether a new note should be added as tied and when a new note is added to a chord by pitch. After this change, when a new note is added to another with a Laissez Vibrer, a single notehead is added, without any tie. This commit also adds a unit test to confirm that a double notehead wasn't created.
1 parent 99c0335 commit 180902b

File tree

5 files changed

+465
-2
lines changed

5 files changed

+465
-2
lines changed

src/engraving/dom/noteentry.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Note* Score::addPitchToChord(NoteVal& nval, Chord* chord, InputState* externalIn
294294
return false;
295295
}
296296
Note* n = ch->notes().at(0);
297-
return n->tieFor() || n->tieBack();
297+
return (n->tieFor() && !n->tieFor()->isLaissezVib()) || n->tieBack();
298298
};
299299

300300
Note* note = nullptr;
@@ -446,7 +446,8 @@ Ret Score::putNote(const Position& p, bool replace)
446446
return false;
447447
}
448448
auto ch = toChord(cr);
449-
return !ch->notes().empty() && !ch->notes()[0]->tieBack() && ch->notes()[0]->tieFor();
449+
return ((!ch->notes().empty() && !ch->notes()[0]->tieBack())
450+
&& (ch->notes()[0]->tieFor() && !ch->notes()[0]->tieFor()->isLaissezVib()));
450451
};
451452

452453
bool addToChord = false;

src/engraving/tests/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ set(MODULE_TEST_SRC
101101
${CMAKE_CURRENT_LIST_DIR}/automation/automation_tests.cpp
102102

103103
${CMAKE_CURRENT_LIST_DIR}/mocks/engravingconfigurationmock.h
104+
105+
${CMAKE_CURRENT_LIST_DIR}/lv_tests.cpp
104106
)
105107

106108
if (MUE_BUILD_ENGRAVING_DEVTOOLS)
Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<museScore version="3.01">
3+
<Score>
4+
<Division>480</Division>
5+
<Style>
6+
<lastSystemFillLimit>0</lastSystemFillLimit>
7+
<Spatium>1.76389</Spatium>
8+
</Style>
9+
<showInvisible>1</showInvisible>
10+
<showUnprintable>1</showUnprintable>
11+
<showFrames>1</showFrames>
12+
<showMargins>0</showMargins>
13+
<metaTag name="arranger"></metaTag>
14+
<metaTag name="composer">Composer</metaTag>
15+
<metaTag name="copyright"></metaTag>
16+
<metaTag name="lyricist"></metaTag>
17+
<metaTag name="movementNumber"></metaTag>
18+
<metaTag name="movementTitle"></metaTag>
19+
<metaTag name="source"></metaTag>
20+
<metaTag name="translator"></metaTag>
21+
<metaTag name="workNumber"></metaTag>
22+
<metaTag name="workTitle">Title</metaTag>
23+
<Part>
24+
<Staff id="1">
25+
<StaffType group="pitched">
26+
<name>stdNormal</name>
27+
</StaffType>
28+
</Staff>
29+
<trackName>Piano</trackName>
30+
<Instrument>
31+
<longName>Piano</longName>
32+
<shortName>Pno.</shortName>
33+
<trackName>Piano</trackName>
34+
<minPitchP>21</minPitchP>
35+
<maxPitchP>108</maxPitchP>
36+
<minPitchA>21</minPitchA>
37+
<maxPitchA>108</maxPitchA>
38+
<clef staff="2">F</clef>
39+
<Articulation>
40+
<velocity>100</velocity>
41+
<gateTime>95</gateTime>
42+
</Articulation>
43+
<Articulation name="staccatissimo">
44+
<velocity>100</velocity>
45+
<gateTime>33</gateTime>
46+
</Articulation>
47+
<Articulation name="staccato">
48+
<velocity>100</velocity>
49+
<gateTime>50</gateTime>
50+
</Articulation>
51+
<Articulation name="portato">
52+
<velocity>100</velocity>
53+
<gateTime>67</gateTime>
54+
</Articulation>
55+
<Articulation name="tenuto">
56+
<velocity>100</velocity>
57+
<gateTime>100</gateTime>
58+
</Articulation>
59+
<Articulation name="marcato">
60+
<velocity>120</velocity>
61+
<gateTime>67</gateTime>
62+
</Articulation>
63+
<Articulation name="sforzato">
64+
<velocity>120</velocity>
65+
<gateTime>100</gateTime>
66+
</Articulation>
67+
<Channel>
68+
<program value="0"/>
69+
</Channel>
70+
</Instrument>
71+
</Part>
72+
<Staff id="1">
73+
<VBox>
74+
<height>10</height>
75+
<Text>
76+
<style>title</style>
77+
<text>Title</text>
78+
</Text>
79+
<Text>
80+
<style>composer</style>
81+
<text>Composer</text>
82+
</Text>
83+
</VBox>
84+
<Measure>
85+
<voice>
86+
<TimeSig>
87+
<sigN>4</sigN>
88+
<sigD>4</sigD>
89+
</TimeSig>
90+
<Rest>
91+
<durationType>measure</durationType>
92+
<duration>4/4</duration>
93+
</Rest>
94+
</voice>
95+
</Measure>
96+
<Measure>
97+
<voice>
98+
<Rest>
99+
<durationType>measure</durationType>
100+
<duration>4/4</duration>
101+
</Rest>
102+
</voice>
103+
</Measure>
104+
<Measure>
105+
<voice>
106+
<Rest>
107+
<durationType>measure</durationType>
108+
<duration>4/4</duration>
109+
</Rest>
110+
</voice>
111+
</Measure>
112+
<Measure>
113+
<LayoutBreak>
114+
<subtype>line</subtype>
115+
</LayoutBreak>
116+
<voice>
117+
<Rest>
118+
<durationType>measure</durationType>
119+
<duration>4/4</duration>
120+
</Rest>
121+
</voice>
122+
</Measure>
123+
<Measure>
124+
<voice>
125+
<Rest>
126+
<durationType>measure</durationType>
127+
<duration>4/4</duration>
128+
</Rest>
129+
</voice>
130+
</Measure>
131+
<Measure>
132+
<voice>
133+
<Rest>
134+
<durationType>measure</durationType>
135+
<duration>4/4</duration>
136+
</Rest>
137+
</voice>
138+
</Measure>
139+
<Measure>
140+
<voice>
141+
<Rest>
142+
<durationType>measure</durationType>
143+
<duration>4/4</duration>
144+
</Rest>
145+
</voice>
146+
</Measure>
147+
<Measure>
148+
<LayoutBreak>
149+
<subtype>line</subtype>
150+
</LayoutBreak>
151+
<voice>
152+
<Rest>
153+
<durationType>measure</durationType>
154+
<duration>4/4</duration>
155+
</Rest>
156+
</voice>
157+
</Measure>
158+
<Measure>
159+
<voice>
160+
<Rest>
161+
<durationType>measure</durationType>
162+
<duration>4/4</duration>
163+
</Rest>
164+
</voice>
165+
</Measure>
166+
<Measure>
167+
<voice>
168+
<Rest>
169+
<durationType>measure</durationType>
170+
<duration>4/4</duration>
171+
</Rest>
172+
</voice>
173+
</Measure>
174+
<Measure>
175+
<voice>
176+
<Rest>
177+
<durationType>measure</durationType>
178+
<duration>4/4</duration>
179+
</Rest>
180+
</voice>
181+
</Measure>
182+
<Measure>
183+
<LayoutBreak>
184+
<subtype>line</subtype>
185+
</LayoutBreak>
186+
<voice>
187+
<Rest>
188+
<durationType>measure</durationType>
189+
<duration>4/4</duration>
190+
</Rest>
191+
</voice>
192+
</Measure>
193+
<Measure>
194+
<voice>
195+
<Rest>
196+
<durationType>measure</durationType>
197+
<duration>4/4</duration>
198+
</Rest>
199+
</voice>
200+
</Measure>
201+
<Measure>
202+
<voice>
203+
<Rest>
204+
<durationType>measure</durationType>
205+
<duration>4/4</duration>
206+
</Rest>
207+
</voice>
208+
</Measure>
209+
<Measure>
210+
<voice>
211+
<Rest>
212+
<durationType>measure</durationType>
213+
<duration>4/4</duration>
214+
</Rest>
215+
</voice>
216+
</Measure>
217+
<Measure>
218+
<LayoutBreak>
219+
<subtype>line</subtype>
220+
</LayoutBreak>
221+
<voice>
222+
<Rest>
223+
<durationType>measure</durationType>
224+
<duration>4/4</duration>
225+
</Rest>
226+
</voice>
227+
</Measure>
228+
<Measure>
229+
<voice>
230+
<Rest>
231+
<durationType>measure</durationType>
232+
<duration>4/4</duration>
233+
</Rest>
234+
</voice>
235+
</Measure>
236+
<Measure>
237+
<voice>
238+
<Rest>
239+
<durationType>measure</durationType>
240+
<duration>4/4</duration>
241+
</Rest>
242+
</voice>
243+
</Measure>
244+
<Measure>
245+
<voice>
246+
<Rest>
247+
<durationType>measure</durationType>
248+
<duration>4/4</duration>
249+
</Rest>
250+
</voice>
251+
</Measure>
252+
<Measure>
253+
<LayoutBreak>
254+
<subtype>line</subtype>
255+
</LayoutBreak>
256+
<voice>
257+
<Rest>
258+
<durationType>measure</durationType>
259+
<duration>4/4</duration>
260+
</Rest>
261+
</voice>
262+
</Measure>
263+
<Measure>
264+
<voice>
265+
<Rest>
266+
<durationType>measure</durationType>
267+
<duration>4/4</duration>
268+
</Rest>
269+
</voice>
270+
</Measure>
271+
<Measure>
272+
<voice>
273+
<Rest>
274+
<durationType>measure</durationType>
275+
<duration>4/4</duration>
276+
</Rest>
277+
</voice>
278+
</Measure>
279+
<Measure>
280+
<voice>
281+
<Rest>
282+
<durationType>measure</durationType>
283+
<duration>4/4</duration>
284+
</Rest>
285+
</voice>
286+
</Measure>
287+
<Measure>
288+
<LayoutBreak>
289+
<subtype>line</subtype>
290+
</LayoutBreak>
291+
<voice>
292+
<Rest>
293+
<durationType>measure</durationType>
294+
<duration>4/4</duration>
295+
</Rest>
296+
</voice>
297+
</Measure>
298+
<Measure>
299+
<voice>
300+
<Rest>
301+
<durationType>measure</durationType>
302+
<duration>4/4</duration>
303+
</Rest>
304+
</voice>
305+
</Measure>
306+
<Measure>
307+
<voice>
308+
<Rest>
309+
<durationType>measure</durationType>
310+
<duration>4/4</duration>
311+
</Rest>
312+
</voice>
313+
</Measure>
314+
<Measure>
315+
<voice>
316+
<Rest>
317+
<durationType>measure</durationType>
318+
<duration>4/4</duration>
319+
</Rest>
320+
</voice>
321+
</Measure>
322+
<Measure>
323+
<LayoutBreak>
324+
<subtype>line</subtype>
325+
</LayoutBreak>
326+
<voice>
327+
<Rest>
328+
<durationType>measure</durationType>
329+
<duration>4/4</duration>
330+
</Rest>
331+
</voice>
332+
</Measure>
333+
<Measure>
334+
<voice>
335+
<Rest>
336+
<durationType>measure</durationType>
337+
<duration>4/4</duration>
338+
</Rest>
339+
</voice>
340+
</Measure>
341+
<Measure>
342+
<voice>
343+
<Rest>
344+
<durationType>measure</durationType>
345+
<duration>4/4</duration>
346+
</Rest>
347+
</voice>
348+
</Measure>
349+
<Measure>
350+
<voice>
351+
<Rest>
352+
<durationType>measure</durationType>
353+
<duration>4/4</duration>
354+
</Rest>
355+
</voice>
356+
</Measure>
357+
<Measure>
358+
<voice>
359+
<Rest>
360+
<durationType>measure</durationType>
361+
<duration>4/4</duration>
362+
</Rest>
363+
<BarLine>
364+
<subtype>end</subtype>
365+
<span>1</span>
366+
</BarLine>
367+
</voice>
368+
</Measure>
369+
</Staff>
370+
</Score>
371+
</museScore>
25 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)