fixes handling of incomplete databases (missing tx on relation)

This commit is contained in:
2026-04-10 09:29:31 +02:00
parent 17015f1bbc
commit 360df27a53
3 changed files with 15 additions and 7 deletions

View File

@@ -105,7 +105,7 @@ class TxRelation implements ITxRelation {
TxStream fiber = loader.txStreams.get(fiberId); TxStream fiber = loader.txStreams.get(fiberId);
fiber.loadStream(); fiber.loadStream();
tx = loader.getTransaction(txId); tx = loader.getTransaction(txId);
return loader.txStreams.get(fiberId); return fiber;
} else } else
return tx.getStream(); return tx.getStream();
} }
@@ -116,7 +116,7 @@ class TxRelation implements ITxRelation {
loader.txStreams.get(fiberId).loadStream(); loader.txStreams.get(fiberId).loadStream();
tx = loader.getTransaction(txId); tx = loader.getTransaction(txId);
} }
return tx.getGenerator(); return tx!=null?tx.getGenerator():null;
} }
@Override @Override

View File

@@ -73,6 +73,7 @@ class TxStream extends AbstractTxStream {
} }
public void loadStream() { public void loadStream() {
if(chunks.size()>0) return;
try { try {
List<byte[]> chunks = getChunks(); List<byte[]> chunks = getChunks();
int blockid = 0; int blockid = 0;

View File

@@ -842,7 +842,7 @@ public class WaveformView implements IWaveformView {
public void setSelection(ISelection selection, boolean add, boolean addIfNeeded) { public void setSelection(ISelection selection, boolean add, boolean addIfNeeded) {
boolean selectionChanged = false; boolean selectionChanged = false;
currentWaveformSelection.forEach(e -> e.selected = false); currentWaveformSelection.forEach(e -> {if(e!=null) e.selected = false;});
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection) selection; IStructuredSelection sel = (IStructuredSelection) selection;
if (sel.size() == 0) { if (sel.size() == 0) {
@@ -862,10 +862,14 @@ public class WaveformView implements IWaveformView {
if (trackEntry == null) { if (trackEntry == null) {
trackEntry = getEntryFor(txSel); trackEntry = getEntryFor(txSel);
if (trackEntry == null && addIfNeeded) { if (trackEntry == null && addIfNeeded) {
IWaveform stream = txSel.getStream();
Optional<TrackEntry> te = streams.stream().filter(e -> stream.equals(e.waveform)).findFirst();
if (te.isEmpty()) { // add stream only if really needed
trackEntry = new TrackEntry(txSel.getStream(), styleProvider); trackEntry = new TrackEntry(txSel.getStream(), styleProvider);
streams.add(trackEntry); streams.add(trackEntry);
} }
} }
}
currentTxSelection = txSel; currentTxSelection = txSel;
currentWaveformSelection.clear(); currentWaveformSelection.clear();
currentWaveformSelection.add(trackEntry); currentWaveformSelection.add(trackEntry);
@@ -885,7 +889,7 @@ public class WaveformView implements IWaveformView {
currentTxSelection = null; currentTxSelection = null;
currentWaveformSelection.clear(); currentWaveformSelection.clear();
} }
currentWaveformSelection.forEach(e -> e.selected = true); currentWaveformSelection.forEach(e -> {if(e!=null)e.selected = true;});
if (selectionChanged) { if (selectionChanged) {
currentWaveformSelection.forEach(e -> waveformCanvas.reveal(e.waveform)); currentWaveformSelection.forEach(e -> waveformCanvas.reveal(e.waveform));
waveformCanvas.setSelected(currentTxSelection); waveformCanvas.setSelected(currentTxSelection);
@@ -1376,10 +1380,13 @@ public class WaveformView implements IWaveformView {
} }
public TrackEntry getEntryFor(ITx source) { public TrackEntry getEntryFor(ITx source) {
Optional<TrackEntry> optGen = streams.stream().filter(e -> source.getGenerator().equals(e.waveform)) if(source.getGenerator()==null) return null;
Optional<TrackEntry> optGen = streams.stream()
.filter(e -> source.getGenerator().equals(e.waveform))
.findFirst(); .findFirst();
if (optGen.isPresent()) if (optGen.isPresent())
return optGen.get(); return optGen.get();
if(source.getStream()==null) return null;
Optional<TrackEntry> optStr = streams.stream().filter(e -> source.getStream().equals(e.waveform)).findFirst(); Optional<TrackEntry> optStr = streams.stream().filter(e -> source.getStream().equals(e.waveform)).findFirst();
if (optStr.isPresent()) if (optStr.isPresent())
return optStr.get(); return optStr.get();