Fixed #20 - NPE gets caught when opening a damaged file and info popup
is shown
This commit is contained in:
parent
7e2869b7ee
commit
3d043ce1b7
|
@ -80,6 +80,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
.allocateStartSize(64*1024*1024)
|
.allocateStartSize(64*1024*1024)
|
||||||
.allocateIncrement(64*1024*1024)
|
.allocateIncrement(64*1024*1024)
|
||||||
.make()
|
.make()
|
||||||
|
// NPE here --->
|
||||||
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
parseInput(gzipped?new GZIPInputStream(new FileInputStream(file)):new FileInputStream(file))
|
||||||
calculateConcurrencyIndicees()
|
calculateConcurrencyIndicees()
|
||||||
return true
|
return true
|
||||||
|
@ -87,6 +88,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
} catch(EOFException e) {
|
} catch(EOFException e) {
|
||||||
return true;
|
return true;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
System.out.println("---->>> Exception caught while loading database. StackTrace following... ");
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -158,6 +158,7 @@ public class WaveformViewer implements IWaveformViewer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseUp(MouseEvent e) {
|
public void mouseUp(MouseEvent e) {
|
||||||
|
if(start==null) return;
|
||||||
if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier
|
if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier
|
||||||
if (e.button == 1 && ((e.stateMask&SWT.SHIFT)==0)) {
|
if (e.button == 1 && ((e.stateMask&SWT.SHIFT)==0)) {
|
||||||
if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){
|
if(Math.abs(e.x-start.x)<3 && Math.abs(e.y-start.y)<3){
|
||||||
|
|
|
@ -74,7 +74,8 @@ import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Event;
|
import org.eclipse.swt.widgets.Event;
|
||||||
import org.eclipse.swt.widgets.Listener;
|
import org.eclipse.swt.widgets.Listener;
|
||||||
import org.eclipse.swt.widgets.TypedListener;
|
import org.eclipse.swt.widgets.MessageBox;
|
||||||
|
|
||||||
import com.minres.scviewer.database.ITx;
|
import com.minres.scviewer.database.ITx;
|
||||||
import com.minres.scviewer.database.ITxEvent;
|
import com.minres.scviewer.database.ITxEvent;
|
||||||
import com.minres.scviewer.database.ITxRelation;
|
import com.minres.scviewer.database.ITxRelation;
|
||||||
|
@ -489,7 +490,17 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
job.addJobChangeListener(new JobChangeAdapter() {
|
job.addJobChangeListener(new JobChangeAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void done(IJobChangeEvent event) {
|
public void done(IJobChangeEvent event) {
|
||||||
if (event.getResult().getCode() != Status.OK_STATUS.getCode()) return;
|
IStatus result = event.getResult();
|
||||||
|
if( (!result.isMultiStatus() && result.getCode() != Status.OK_STATUS.getCode() ) ||
|
||||||
|
(result.isMultiStatus() && result.getChildren().length > 0 && result.getChildren()[0].getCode() != Status.OK_STATUS.getCode() ) ){
|
||||||
|
// kill editor and pop up warning for user
|
||||||
|
sync.asyncExec(() -> {
|
||||||
|
final Display display = myParent.getDisplay();
|
||||||
|
MessageDialog.openWarning(display.getActiveShell(), "Error loading database", "Database cannot be loaded. Aborting...");
|
||||||
|
ePartService.hidePart(myPart, true);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
sync.asyncExec(()->{
|
sync.asyncExec(()->{
|
||||||
waveformPane.setMaxTime(database.getMaxTime());
|
waveformPane.setMaxTime(database.getMaxTime());
|
||||||
if (state != null)
|
if (state != null)
|
||||||
|
|
Loading…
Reference in New Issue