Cleaned up removing menu entry, added exception throwing

This commit is contained in:
nathan 2016-09-26 21:46:41 +02:00
parent 19eb4df547
commit 180d66a7c1

View File

@ -1181,22 +1181,26 @@ class SystemTray {
@Override
public
void run() {
synchronized (menuEntries) {
for (Iterator<MenuEntry> iterator = menuEntries.iterator(); iterator.hasNext(); ) {
final MenuEntry entry = iterator.next();
if (entry.getText()
.equals(label)) {
iterator.remove();
try {
synchronized (menuEntries) {
for (Iterator<MenuEntry> iterator = menuEntries.iterator(); iterator.hasNext(); ) {
final MenuEntry entry = iterator.next();
if (entry.getText()
.equals(label)) {
iterator.remove();
// this will also reset the menu
menuEntry.remove();
hasValue.set(true);
countDownLatch.countDown();
return;
// this will also reset the menu
menuEntry.remove();
hasValue.set(true);
break;
}
}
}
} catch (Exception e) {
logger.error("Error removing menu entry from list.", e);
} finally {
countDownLatch.countDown();
}
countDownLatch.countDown();
}
});