fixes database reopening problem due to locking

This commit is contained in:
Eyck Jentzsch 2023-03-01 12:53:34 +01:00
parent f64a1baf02
commit 6769513e2d
9 changed files with 83 additions and 5 deletions

View File

@ -62,4 +62,13 @@ public interface IWaveformDb extends IHierNode {
*/
public boolean isLoaded();
/**
* close an open database.
*
* @param inp the inp
* @return true, if successful
*/
public void close();
}

View File

@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
@ -39,6 +40,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
/** The loaders. */
private static List<IWaveformDbLoaderFactory> loaderFactories = new LinkedList<>();
private List<IWaveformDbLoader> activeLoader = new ArrayList<>();
/** The loaded. */
private boolean loaded;
@ -136,6 +138,7 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
loader.addPropertyChangeListener(this);
try {
loader.load(inp);
activeLoader.add(loader);
} catch (Exception e) {
LOG.error("error loading file "+inp.getName(), e);
retval=false;
@ -158,6 +161,12 @@ public class WaveformDb extends HierNode implements IWaveformDb, PropertyChangeL
return retval;
}
@Override
public void close() {
for (IWaveformDbLoader entry : activeLoader) {
entry.dispose();
}
}
/**
* Gets the file basename.
*

View File

@ -124,7 +124,7 @@ public class RelationTypeToolControl extends PartListener implements ISelectionC
return;
}
}
if(comboViewer!=null) comboViewer.getCombo().setEnabled(false);
if(comboViewer!=null && !comboViewer.getCombo().isDisposed()) comboViewer.getCombo().setEnabled(false);
}
/* (non-Javadoc)

View File

@ -35,8 +35,12 @@ public class AddSeparatorHandler {
Object sel = ((WaveformViewer)part.getObject()).getSelection();
if( sel instanceof IStructuredSelection) {
if(((IStructuredSelection)sel).isEmpty()) return false;
Object o= ((IStructuredSelection)sel).getFirstElement();
return o instanceof TrackEntry;
IStructuredSelection isel = (IStructuredSelection) sel;
if(isel.size()==1)
return isel.getFirstElement() instanceof TrackEntry;
else if(isel.size()==2) {
return isel.toArray()[1] instanceof TrackEntry;
}
}
}
return false;

View File

@ -23,13 +23,13 @@ public class SelectAllHandler {
@CanExecute
public boolean canExecute(EPartService partService) {
MPart part = partService.getActivePart();
return part.getObject() instanceof WaveformViewer;
return part!=null && part.getObject() instanceof WaveformViewer;
}
@Execute
public void execute(EPartService partService) {
MPart part = partService.getActivePart();
if(part.getObject() instanceof WaveformViewer)
if(part!=null && part.getObject() instanceof WaveformViewer)
((WaveformViewer) part.getObject()).selectAll();
}

View File

@ -29,6 +29,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
@ -512,6 +513,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
showTxDetails(false);
}
@PreDestroy
public void closeDatabase() {
if(database.isLoaded())
database.close();
}
@Inject
@Optional
public void reactOnPrefsChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs) {

View File

@ -0,0 +1,49 @@
#Written by SCViewer
#Wed Mar 01 08:49:19 CET 2023
SHOWN_WAVEFORM0=tr.addr_ack
SHOWN_WAVEFORM2=tr.bus_addr[7\:0]
SHOWN_WAVEFORM1=tr.addr_req
SHOWN_WAVEFORM7=tr.rw
SHOWN_WAVEFORM5.WAVEFORM_TYPE=SIGNAL
SHOWN_WAVEFORM4=tr.bus_data[7\:0]
SHOWN_WAVEFORM3=Blank
SHOWN_WAVEFORM6=tr.data_rdy
SHOWN_WAVEFORM5=tr.clk
SHOWN_CURSOR1=100000000
SHOWN_CURSOR0=10000000
SHOWN_WAVEFORM0.WAVEFORM_TYPE=SIGNAL
SHOWN_WAVEFORM5.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM0.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORMS=8
SCALING_FACTOR=1000000
SHOWN_CURSORS=2
SHOWN_WAVEFORM0.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM7.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM3.WAVEFORM_TYPE=EMPTY
SHOWN_WAVEFORM2.WAVEFORM_TYPE=SIGNAL
SHOWN_WAVEFORM6.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM2.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM4.WAVEFORM_TYPE=SIGNAL
DATABASE_FILE0=/scratch/eyck/workarea/MINRES/SCViewer/tests/com.minres.scviewer.database.test/inputs/my_db.vcd
SHOWN_WAVEFORM7.WAVE_DISPLAY=DEFAULT
SHOWN_WAVEFORM7.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM4.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM5.WAVE_DISPLAY=DEFAULT
DATABASE_FILES=1
SHOWN_WAVEFORM1.WAVE_DISPLAY=DEFAULT
SHOWN_WAVEFORM4.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM5.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM1.WAVEFORM_TYPE=SIGNAL
SHOWN_WAVEFORM6.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM6.WAVEFORM_TYPE=SIGNAL
SHOWN_WAVEFORM1.WAVEFORM_SELECTED=FALSE
SHOWN_WAVEFORM4.WAVE_DISPLAY=DEFAULT
SHOWN_WAVEFORM1.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM7.WAVEFORM_TYPE=SIGNAL
TX_DETAILS_SHOWN=false
SHOWN_WAVEFORM2.VALUE_DISPLAY=DEFAULT
SHOWN_WAVEFORM2.WAVE_DISPLAY=DEFAULT
SHOWN_WAVEFORM0.WAVE_DISPLAY=DEFAULT
SHOWN_WAVEFORM6.WAVE_DISPLAY=DEFAULT
BASE_LINE_TIME=0
SHOWN_WAVEFORM3.WAVEFORM_SELECTED=TRUE