From 29cf3a8243e8b172c1b23d7b5321fdb33fd8f35c Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Mon, 25 Feb 2013 09:47:07 +0000 Subject: [PATCH] Dispatches calls to addPopupMessageListener before we have initialized the SystrayService (waiting for UIService). --- .../jdic/SystrayServiceJdicImpl.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java index d6f9446ec..35c02d208 100644 --- a/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/osdependent/jdic/SystrayServiceJdicImpl.java @@ -10,6 +10,7 @@ import java.awt.event.*; import java.net.*; import java.util.*; +import java.util.List; import javax.swing.*; import javax.swing.event.*; @@ -127,6 +128,12 @@ public class SystrayServiceJdicImpl private final SystrayPopupMessageListener popupMessageListener = new SystrayPopupMessageListenerImpl(); + /** + * List of listeners from early received calls to addPopupMessageListener. + * Calls to addPopupMessageListener before the UIService is registered. + */ + private List earlyAddedListeners = null; + /** * Initializes a new SystrayServiceJdicImpl instance. */ @@ -432,6 +439,8 @@ public void showPopupMessage(PopupMessage popupMessage) /** * Implements the SystrayService.addPopupMessageListener method. + * If activePopupHandler is still not available record the listener + * so we can add him later. * * @param listener the listener to add */ @@ -439,6 +448,14 @@ public void addPopupMessageListener(SystrayPopupMessageListener listener) { if (activePopupHandler != null) activePopupHandler.addPopupMessageListener(listener); + else + { + if(earlyAddedListeners == null) + earlyAddedListeners = + new ArrayList(); + + earlyAddedListeners.add(listener); + } } /** @@ -590,6 +607,17 @@ public PopupMessageHandler setActivePopupMessageHandler( + newHandler); } activePopupHandler = newHandler; + // if we have received calls to addPopupMessageListener before + // the UIService is registered we should add those listeners + if(earlyAddedListeners != null) + { + for(SystrayPopupMessageListener l : earlyAddedListeners) + activePopupHandler.addPopupMessageListener(l); + + earlyAddedListeners.clear(); + earlyAddedListeners = null; + } + return oldHandler; }