Skip to content

Commit

Permalink
Bug fix on part ID used as an index
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed May 28, 2018
1 parent e9b8537 commit 0010195
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/main/org/audiveris/omr/sheet/Part.java
Expand Up @@ -114,7 +114,10 @@ public int compare (Part p1,
// Persistent data
//----------------
//
/** Id of this part within the system, or set as logical part ID. */
/**
* Id of this part within the system, or set as logical part ID.
* <b>BEWARE</b>, this ID is not always an index, hence don't use it as an index!
*/
@XmlAttribute
private int id;

Expand Down
16 changes: 8 additions & 8 deletions src/main/org/audiveris/omr/sheet/rhythm/MeasureStack.java
Expand Up @@ -41,9 +41,7 @@
import org.audiveris.omr.sig.inter.StaffBarlineInter;
import org.audiveris.omr.sig.inter.TupletInter;
import org.audiveris.omr.util.HorizontalSide;

import static org.audiveris.omr.util.HorizontalSide.*;

import org.audiveris.omr.util.Jaxb;
import org.audiveris.omr.util.Navigable;

Expand Down Expand Up @@ -1693,15 +1691,17 @@ public void shorten (Rational shortening)
*/
public MeasureStack splitAtBarline (List<PartBarline> systemBarline)
{
final int index = system.getStacks().indexOf(this);
final int stackIndex = system.getStacks().indexOf(this);
final MeasureStack leftStack = new MeasureStack(system);
leftStack.left = this.left;
leftStack.right = 0;
this.left = Integer.MAX_VALUE;

for (Part part : system.getParts()) {
final int ip = part.getId();
final PartBarline partBarline = systemBarline.get(ip - 1);
final List<Part> systemParts = system.getParts();

for (int partIndex = 0; partIndex < systemParts.size(); partIndex++) {
final Part part = systemParts.get(partIndex);
final PartBarline partBarline = systemBarline.get(partIndex);
Map<Staff, Integer> xRefs = new HashMap<Staff, Integer>();

for (Staff staff : part.getStaves()) {
Expand All @@ -1718,7 +1718,7 @@ public MeasureStack splitAtBarline (List<PartBarline> systemBarline)
leftStack.measures.add(leftMeasure);

// Insert leftMeasure into part, just before the old (right) measure
part.addMeasure(index, leftMeasure);
part.addMeasure(stackIndex, leftMeasure);
}

// Stack tuplets (not in any measure yet)
Expand All @@ -1734,7 +1734,7 @@ public MeasureStack splitAtBarline (List<PartBarline> systemBarline)
}

// Insert leftStack into system, just before this old (right) stack
system.addStack(index, leftStack);
system.addStack(stackIndex, leftStack);

return leftStack;
}
Expand Down

0 comments on commit 0010195

Please sign in to comment.