Browse Source

cmXScore.c : Fixed bug in _cmXScoreRemoveNote() which prevented notes from being removed.

master
kevin 7 years ago
parent
commit
1caa200c90
1 changed files with 20 additions and 6 deletions
  1. 20
    6
      app/cmXScore.c

+ 20
- 6
app/cmXScore.c View File

274
 }
274
 }
275
 
275
 
276
 
276
 
277
-void _cmXScoreRemoveNote( cmXsNote_t* note )
277
+cmXsRC_t  _cmXScoreRemoveNote( cmXsNote_t* note )
278
 {
278
 {
279
   cmXsNote_t* n0 = NULL;
279
   cmXsNote_t* n0 = NULL;
280
   cmXsNote_t* n1 = note->voice->noteL;
280
   cmXsNote_t* n1 = note->voice->noteL;
281
-  
281
+  unsigned    cnt = 0;
282
   for(; n1!=NULL; n1=n1->mlink)
282
   for(; n1!=NULL; n1=n1->mlink)
283
+  {
283
     if( n1->uid == note->uid )
284
     if( n1->uid == note->uid )
284
     {
285
     {
285
       if( n0 == NULL )
286
       if( n0 == NULL )
287
       else
288
       else
288
         n0->mlink = n1->mlink;
289
         n0->mlink = n1->mlink;
289
 
290
 
291
+      cnt = 1;
290
       break;
292
       break;
291
     }
293
     }
292
 
294
 
295
+    n0 = n1;
296
+  }
297
+  
293
   n0 = NULL;
298
   n0 = NULL;
294
   n1 = note->meas->noteL;
299
   n1 = note->meas->noteL;
295
   for(; n1!=NULL; n1=n1->slink)
300
   for(; n1!=NULL; n1=n1->slink)
301
+  {
296
     if( n1->uid == note->uid )
302
     if( n1->uid == note->uid )
297
     {
303
     {
298
       if( n0 == NULL )
304
       if( n0 == NULL )
300
       else
306
       else
301
         n0->slink = n1->slink;
307
         n0->slink = n1->slink;
302
 
308
 
309
+      cnt = 2;
303
       break;
310
       break;
304
     }
311
     }
312
+    
313
+    n0 = n1;
314
+  }
315
+  return cnt == 2 ? kOkXsRC : kSyntaxErrorXsRC;
305
  
316
  
306
 }
317
 }
307
 
318
 
308
 void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
319
 void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
309
 {
320
 {
321
+  assert( note != NULL );
322
+  
310
   // insert the new note into the voice list before 'note'
323
   // insert the new note into the voice list before 'note'
311
   cmXsNote_t* n0 = NULL;
324
   cmXsNote_t* n0 = NULL;
312
   cmXsNote_t* n1 = note->voice->noteL;
325
   cmXsNote_t* n1 = note->voice->noteL;
2145
   // remove deleted notes
2158
   // remove deleted notes
2146
   for(i=0; i<rN; ++i)
2159
   for(i=0; i<rN; ++i)
2147
     if( cmIsFlag(rV[i].newFlags,kDeleteXsFl) )
2160
     if( cmIsFlag(rV[i].newFlags,kDeleteXsFl) )
2148
-      _cmXScoreRemoveNote( rV[i].note );
2161
+      if( _cmXScoreRemoveNote( rV[i].note ) != kOkXsRC )
2162
+        return cmErrMsg(&p->err,kSyntaxErrorXsRC,"Event marked to skip was not found in measure: %i",measNumb);
2149
       
2163
       
2150
   cmXsMeas_t* mp  = rV[0].note->meas;
2164
   cmXsMeas_t* mp  = rV[0].note->meas;
2151
   cmXsNote_t* n0p = NULL;
2165
   cmXsNote_t* n0p = NULL;
3291
 
3305
 
3292
   if( cmIsFlag(note->flags,kEndGraceXsFl) )
3306
   if( cmIsFlag(note->flags,kEndGraceXsFl) )
3293
     cmRptPrintf(rpt," E");
3307
     cmRptPrintf(rpt," E");
3294
-
3295
-
3308
+    
3296
   if( cmIsFlag(note->flags,kDynBegForkXsFl) )
3309
   if( cmIsFlag(note->flags,kDynBegForkXsFl) )
3297
     cmRptPrintf(rpt," B");
3310
     cmRptPrintf(rpt," B");
3298
 
3311
 
3299
   if( cmIsFlag(note->flags,kDynEndForkXsFl) )
3312
   if( cmIsFlag(note->flags,kDynEndForkXsFl) )
3300
     cmRptPrintf(rpt," E");
3313
     cmRptPrintf(rpt," E");
3301
-  */  
3314
+  */
3315
+    
3302
 }
3316
 }
3303
 
3317
 
3304
 
3318
 

Loading…
Cancel
Save