@@ -2409,11 +2409,12 @@ public void handleSerial() {
2409
2409
}
2410
2410
2411
2411
try {
2412
- serialMonitor .setVisible (true );
2413
2412
if (!avoidMultipleOperations ) {
2414
2413
serialMonitor .open ();
2415
2414
}
2415
+ serialMonitor .setVisible (true );
2416
2416
success = true ;
2417
+ statusEmpty ();
2417
2418
} catch (ConnectException e ) {
2418
2419
statusError (tr ("Unable to connect: is the sketch using the bridge?" ));
2419
2420
} catch (JSchException e ) {
@@ -2423,6 +2424,7 @@ public void handleSerial() {
2423
2424
if (e .getCause () != null && e .getCause () instanceof SerialPortException ) {
2424
2425
errorMessage += " (" + ((SerialPortException ) e .getCause ()).getExceptionType () + ")" ;
2425
2426
}
2427
+ serialMonitor = null ;
2426
2428
statusError (errorMessage );
2427
2429
try {
2428
2430
serialMonitor .close ();
@@ -2432,12 +2434,12 @@ public void handleSerial() {
2432
2434
} catch (Exception e ) {
2433
2435
statusError (e );
2434
2436
} finally {
2435
- if (serialMonitor .requiresAuthorization () && !success ) {
2437
+ if (serialMonitor != null && serialMonitor .requiresAuthorization () && !success ) {
2436
2438
PreferencesData .remove (serialMonitor .getAuthorizationKey ());
2437
2439
}
2438
2440
}
2439
2441
2440
- } while (serialMonitor .requiresAuthorization () && !success );
2442
+ } while (serialMonitor != null && serialMonitor .requiresAuthorization () && !success );
2441
2443
2442
2444
}
2443
2445
@@ -2457,6 +2459,7 @@ public void handlePlotter() {
2457
2459
if (serialPlotter .isClosed ()) {
2458
2460
// If it's closed, clear the refrence to the existing
2459
2461
// plotter and create a new one
2462
+ serialPlotter .dispose ();
2460
2463
serialPlotter = null ;
2461
2464
}
2462
2465
else {
@@ -2510,6 +2513,7 @@ public void handlePlotter() {
2510
2513
serialPlotter .open ();
2511
2514
serialPlotter .setVisible (true );
2512
2515
success = true ;
2516
+ statusEmpty ();
2513
2517
} catch (ConnectException e ) {
2514
2518
statusError (tr ("Unable to connect: is the sketch using the bridge?" ));
2515
2519
} catch (JSchException e ) {
@@ -2520,15 +2524,16 @@ public void handlePlotter() {
2520
2524
errorMessage += " (" + ((SerialPortException ) e .getCause ()).getExceptionType () + ")" ;
2521
2525
}
2522
2526
statusError (errorMessage );
2527
+ serialPlotter = null ;
2523
2528
} catch (Exception e ) {
2524
2529
statusError (e );
2525
2530
} finally {
2526
- if (serialPlotter .requiresAuthorization () && !success ) {
2531
+ if (serialPlotter != null && serialPlotter .requiresAuthorization () && !success ) {
2527
2532
PreferencesData .remove (serialPlotter .getAuthorizationKey ());
2528
2533
}
2529
2534
}
2530
2535
2531
- } while (serialPlotter .requiresAuthorization () && !success );
2536
+ } while (serialPlotter != null && serialPlotter .requiresAuthorization () && !success );
2532
2537
2533
2538
}
2534
2539
0 commit comments