Better checking when setting tooltip text

This commit is contained in:
nathan 2017-07-09 16:02:34 +02:00
parent 3125fb6b0e
commit 78b78b80b9
3 changed files with 14 additions and 2 deletions

View File

@ -49,7 +49,7 @@ class _AwtTray extends Tray implements NativeUI {
// is the system tray visible or not.
private volatile boolean visible = true;
private volatile File imageFile;
private volatile String tooltipText = null;
private volatile String tooltipText = "";
private final Object keepAliveLock = new Object[0];
private Thread keepAliveThread;
@ -212,6 +212,9 @@ class _AwtTray extends Tray implements NativeUI {
@Override
protected
void setTooltip_(final String tooltipText) {
if (this.tooltipText.equals(tooltipText)){
return;
}
this.tooltipText = tooltipText;
SwingUtil.invokeLater(new Runnable() {

View File

@ -54,6 +54,7 @@ class _GtkStatusIconNativeTray extends Tray implements NativeUI {
// is the system tray visible or not.
private volatile boolean visible = true;
private volatile File imageFile;
private volatile String tooltipText = "";
private final GtkMenu gtkMenu;
@ -205,6 +206,11 @@ class _GtkStatusIconNativeTray extends Tray implements NativeUI {
@Override
protected
void setTooltip_(final String tooltipText) {
if (this.tooltipText.equals(tooltipText)){
return;
}
this.tooltipText = tooltipText;
Gtk.dispatch(new Runnable() {
@Override
public

View File

@ -49,7 +49,7 @@ class _SwingTray extends Tray implements SwingUI {
// is the system tray visible or not.
private volatile boolean visible = true;
private volatile File imageFile;
private volatile String tooltipText = null;
private volatile String tooltipText = "";
// Called in the EDT
public
@ -202,6 +202,9 @@ class _SwingTray extends Tray implements SwingUI {
@Override
protected
void setTooltip_(final String tooltipText) {
if (this.tooltipText.equals(tooltipText)){
return;
}
this.tooltipText = tooltipText;
SwingUtil.invokeLater(new Runnable() {