Fixed *.remove() methods for GTK, so they are continuously executed on

the GTK thread.
This commit is contained in:
nathan 2017-09-17 21:01:00 +02:00
parent 104717c016
commit 46c8bb712e
5 changed files with 54 additions and 12 deletions

View File

@ -252,7 +252,7 @@ class GtkMenu extends GtkBaseMenuItem implements MenuPeer {
// is overridden by system tray // is overridden by system tray
setLegitImage(menuItem.getImage() != null); setLegitImage(menuItem.getImage() != null);
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -273,7 +273,14 @@ class GtkMenu extends GtkBaseMenuItem implements MenuPeer {
Gtk2.gtk_widget_show_all(_native); Gtk2.gtk_widget_show_all(_native);
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
// is overridden in tray impl // is overridden in tray impl
@ -378,7 +385,7 @@ class GtkMenu extends GtkBaseMenuItem implements MenuPeer {
@Override @Override
public public
void remove() { void remove() {
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -401,6 +408,13 @@ class GtkMenu extends GtkBaseMenuItem implements MenuPeer {
parent.createMenu(); // must be on EDT parent.createMenu(); // must be on EDT
} }
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
} }

View File

@ -185,7 +185,7 @@ class GtkMenuItem extends GtkBaseMenuItem implements MenuItemPeer, GCallback {
@Override @Override
public public
void remove() { void remove() {
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -201,6 +201,13 @@ class GtkMenuItem extends GtkBaseMenuItem implements MenuItemPeer, GCallback {
parent.remove(GtkMenuItem.this); parent.remove(GtkMenuItem.this);
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
} }

View File

@ -291,7 +291,7 @@ class GtkMenuItemCheckbox extends GtkBaseMenuItem implements CheckboxPeer, GCall
@Override @Override
public public
void remove() { void remove() {
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -306,6 +306,13 @@ class GtkMenuItemCheckbox extends GtkBaseMenuItem implements CheckboxPeer, GCall
parent.remove(GtkMenuItemCheckbox.this); parent.remove(GtkMenuItemCheckbox.this);
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
} }

View File

@ -37,7 +37,7 @@ class GtkMenuItemSeparator extends GtkBaseMenuItem implements EntryPeer {
@Override @Override
public public
void remove() { void remove() {
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -45,7 +45,14 @@ class GtkMenuItemSeparator extends GtkBaseMenuItem implements EntryPeer {
parent.remove(GtkMenuItemSeparator.this); parent.remove(GtkMenuItemSeparator.this);
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
@Override @Override

View File

@ -61,7 +61,7 @@ class GtkMenuItemStatus extends GtkBaseMenuItem implements StatusPeer {
@Override @Override
public public
void remove() { void remove() {
GtkEventDispatch.dispatch(new Runnable() { Runnable runnable = new Runnable() {
@Override @Override
public public
void run() { void run() {
@ -71,6 +71,13 @@ class GtkMenuItemStatus extends GtkBaseMenuItem implements StatusPeer {
parent.remove(GtkMenuItemStatus.this); parent.remove(GtkMenuItemStatus.this);
} }
}); };
if (GtkEventDispatch.isDispatch.get()) {
runnable.run();
}
else {
GtkEventDispatch.dispatch(runnable);
}
} }
} }