fixes some divide by zero exception while drawing

This commit is contained in:
Eyck Jentzsch 2023-02-23 21:10:57 +01:00
parent c8e587c1ea
commit ceaf52bfa1
2 changed files with 5 additions and 10 deletions

View File

@ -328,7 +328,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
long array_len = readArrayLength();
assert(array_len==-1);
CborType next = peekType();
int chunk_idx=0;
while(next != null && !break_type.isEqualType(next)) {
long tag = readTag();
switch((int)tag) {
@ -400,7 +399,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
}
}
next = peekType();
chunk_idx++;
}
} catch(IOException e) {
long pos = 0;
@ -468,7 +466,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
long tx_size = cborDecoder.readArrayLength();
long txId = 0;
long genId = 0;
long attr_idx=0;
for(long i = 0; i<tx_size; ++i) {
long tag = cborDecoder.readTag();
switch((int)tag) {
@ -497,10 +494,8 @@ public class FtrDbLoader implements IWaveformDbLoader {
default: { // skip over 7:begin attr, 8:record attr, 9:end attr
long sz = cborDecoder.readArrayLength();
assert(sz==3);
long name_id = cborDecoder.readInt();
String name = loader.strDict.get((int)name_id);
long type_id = cborDecoder.readInt();
switch((int)type_id) {
cborDecoder.readInt();
switch((int)cborDecoder.readInt()) {
case 0: // BOOLEAN
cborDecoder.readBoolean();
break;
@ -512,7 +507,6 @@ public class FtrDbLoader implements IWaveformDbLoader {
default:
cborDecoder.readInt();
}
attr_idx++;
}
}
}

View File

@ -56,8 +56,9 @@ public class RulerPainter implements IPainter {
int baselineY=waveCanvas.rulerHeight - 1;
int bottom=waveCanvas.rulerHeight - 2;
long safe_scale_factor = scaleFactor!=0?scaleFactor:1;
long startTickTime = startTime+rulerTickMinor-(startTime % rulerTickMinor);
long majorTickDist = rulerTickMajor/scaleFactor;
long majorTickDist = rulerTickMajor/safe_scale_factor;
gc.setBackground(waveCanvas.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
gc.fillRectangle(new Rectangle(area.x, area.y, area.width, waveCanvas.rulerHeight));
@ -75,7 +76,7 @@ public class RulerPainter implements IPainter {
boolean drawEvery = majorTickDist>maxTextLength;
boolean drawText=true;
for (long tickTime = startTickTime; tickTime < endTime; tickTime+= rulerTickMinor) {
int x0Pos = (int) (tickTime/scaleFactor) + proj.getTranslation().x;
int x0Pos = (int) (tickTime/safe_scale_factor) + proj.getTranslation().x;
if ((tickTime % rulerTickMajor) == 0) {
if(drawEvery || drawText)
gc.drawText(waveCanvas.timeToString(tickTime), x0Pos, area.y+textY);