Просмотр исходного кода

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

master
kevin 7 лет назад
Родитель
Сommit
1caa200c90
1 измененных файлов: 20 добавлений и 6 удалений
  1. 20
    6
      app/cmXScore.c

+ 20
- 6
app/cmXScore.c Просмотреть файл

@@ -274,12 +274,13 @@ cmXsRC_t _cmXScorePushNote( cmXScore_t* p, cmXsMeas_t* meas, unsigned voiceId, c
274 274
 }
275 275
 
276 276
 
277
-void _cmXScoreRemoveNote( cmXsNote_t* note )
277
+cmXsRC_t  _cmXScoreRemoveNote( cmXsNote_t* note )
278 278
 {
279 279
   cmXsNote_t* n0 = NULL;
280 280
   cmXsNote_t* n1 = note->voice->noteL;
281
-  
281
+  unsigned    cnt = 0;
282 282
   for(; n1!=NULL; n1=n1->mlink)
283
+  {
283 284
     if( n1->uid == note->uid )
284 285
     {
285 286
       if( n0 == NULL )
@@ -287,12 +288,17 @@ void _cmXScoreRemoveNote( cmXsNote_t* note )
287 288
       else
288 289
         n0->mlink = n1->mlink;
289 290
 
291
+      cnt = 1;
290 292
       break;
291 293
     }
292 294
 
295
+    n0 = n1;
296
+  }
297
+  
293 298
   n0 = NULL;
294 299
   n1 = note->meas->noteL;
295 300
   for(; n1!=NULL; n1=n1->slink)
301
+  {
296 302
     if( n1->uid == note->uid )
297 303
     {
298 304
       if( n0 == NULL )
@@ -300,13 +306,20 @@ void _cmXScoreRemoveNote( cmXsNote_t* note )
300 306
       else
301 307
         n0->slink = n1->slink;
302 308
 
309
+      cnt = 2;
303 310
       break;
304 311
     }
312
+    
313
+    n0 = n1;
314
+  }
315
+  return cnt == 2 ? kOkXsRC : kSyntaxErrorXsRC;
305 316
  
306 317
 }
307 318
 
308 319
 void _cmXScoreInsertNoteBefore( cmXsNote_t* note, cmXsNote_t* nn )
309 320
 {
321
+  assert( note != NULL );
322
+  
310 323
   // insert the new note into the voice list before 'note'
311 324
   cmXsNote_t* n0 = NULL;
312 325
   cmXsNote_t* n1 = note->voice->noteL;
@@ -2145,7 +2158,8 @@ cmXsRC_t _cmXScoreReorderMeas( cmXScore_t* p, unsigned measNumb, cmXsReorder_t*
2145 2158
   // remove deleted notes
2146 2159
   for(i=0; i<rN; ++i)
2147 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 2164
   cmXsMeas_t* mp  = rV[0].note->meas;
2151 2165
   cmXsNote_t* n0p = NULL;
@@ -3291,14 +3305,14 @@ void _cmXScoreReportNote( cmRpt_t* rpt, const cmXsNote_t* note,unsigned index )
3291 3305
 
3292 3306
   if( cmIsFlag(note->flags,kEndGraceXsFl) )
3293 3307
     cmRptPrintf(rpt," E");
3294
-
3295
-
3308
+    
3296 3309
   if( cmIsFlag(note->flags,kDynBegForkXsFl) )
3297 3310
     cmRptPrintf(rpt," B");
3298 3311
 
3299 3312
   if( cmIsFlag(note->flags,kDynEndForkXsFl) )
3300 3313
     cmRptPrintf(rpt," E");
3301
-  */  
3314
+  */
3315
+    
3302 3316
 }
3303 3317
 
3304 3318
 

Загрузка…
Отмена
Сохранить