Removes race condition between protocol and UI thread, when closing the call panel. The call panel was sometime (everytime on Linux) not closed until clicking at least 2 times on the hangup button.

cusax-fix
Vincent Lucas 13 years ago
parent 119d45b860
commit f40f0cb21e

@ -199,9 +199,9 @@ else if (CallState.CALL_ENDED.equals(newValue))
@Override
public void callEndedInEventDispatchThread(CallEvent ev)
{
Call sourceCall = ev.getSourceCall();
CallConference callConference = ev.getCallConference();
closeCallContainerIfNotNecessary(sourceCall);
closeCallContainerIfNotNecessary(callConference);
/*
* Notify the existing CallPanels about the CallEvent (in case
@ -1050,31 +1050,19 @@ public static void transferCall(CallPeer peer, String target)
* longer necessary (i.e. is not used by other <tt>Call</tt>s participating
* in the same telephony conference as the specified <tt>Call</tt>.)
*
* @param call the <tt>Call</tt> which is to have its associated
* <tt>CallPanel</tt>, if any, closed
* @param callConference The <tt>CallConference</tt> which is to have its
* associated <tt>CallPanel</tt>, if any, closed
* {@link CallContainer#closeWait(CallPanel)} or <tt>false</tt> to use
* {@link CallContainer#close(CallPanel)}
*/
private static void closeCallContainerIfNotNecessary(final Call call)
private static void closeCallContainerIfNotNecessary(
final CallConference callConference)
{
if (!SwingUtilities.isEventDispatchThread())
{
SwingUtilities.invokeLater(
new Runnable()
{
public void run()
{
closeCallContainerIfNotNecessary(call);
}
});
return;
}
CallPanel callPanel = callPanels.get(call.getConference());
CallPanel callPanel = callPanels.get(callConference);
if (callPanel != null)
closeCallContainerIfNotNecessary(
call, callPanel.isCloseWaitAfterHangup());
callConference, callPanel.isCloseWaitAfterHangup());
}
/**
@ -1082,14 +1070,14 @@ public void run()
* longer necessary (i.e. is not used by other <tt>Call</tt>s participating
* in the same telephony conference as the specified <tt>Call</tt>.)
*
* @param call the <tt>Call</tt> which is to have its associated
* <tt>CallPanel</tt>, if any, closed
* @param callConference The <tt>CallConference</tt> which is to have its
* associated <tt>CallPanel</tt>, if any, closed
* @param wait <tt>true</tt> to use
* {@link CallContainer#closeWait(CallPanel)} or <tt>false</tt> to use
* {@link CallContainer#close(CallPanel)}
*/
private static void closeCallContainerIfNotNecessary(
final Call call,
final CallConference callConference,
final boolean wait)
{
if (!SwingUtilities.isEventDispatchThread())
@ -1099,7 +1087,9 @@ private static void closeCallContainerIfNotNecessary(
{
public void run()
{
closeCallContainerIfNotNecessary(call, wait);
closeCallContainerIfNotNecessary(
callConference,
wait);
}
});
return;
@ -1114,8 +1104,6 @@ public void run()
* the AWT event dispatching thread.
*/
CallConference conference = call.getConference();
for (Iterator<Map.Entry<CallConference, CallPanel>> entryIter
= callPanels.entrySet().iterator();
entryIter.hasNext();)
@ -1133,7 +1121,7 @@ public void run()
{
window.close(
aCallPanel,
wait && (aConference == conference));
wait && (aConference == callConference));
}
finally
{
@ -2596,7 +2584,7 @@ public void run()
* Dispose of the CallPanel associated with the Call which
* is to be merged.
*/
closeCallContainerIfNotNecessary(call, false);
closeCallContainerIfNotNecessary(conference, false);
call.setConference(conference);
}

@ -56,6 +56,14 @@ public class CallEvent
*/
private final Map<MediaType, MediaDirection> mediaDirections;
/**
* The conference of the call for this event. Must be set when creating this
* event, because when a call ends, the call conference may be released just
* after creating this event, but its reference will still be necessary in
* the futur for the UI (i.e to release the call panel),
*/
private final CallConference conference;
/**
* Creates an event instance indicating that an incoming/outgoing call
* has been created
@ -96,6 +104,8 @@ public CallEvent(
if (mediaDirections != null)
thisMediaDirections.putAll(mediaDirections);
this.mediaDirections = Collections.unmodifiableMap(thisMediaDirections);
this.conference = call.getConference();
}
/**
@ -139,6 +149,16 @@ public Call getSourceCall()
return (Call)getSource();
}
/**
* Returns the <tt>CallConference</tt> that triggered this event.
*
* @return the <tt>CallConference</tt> that triggered this event.
*/
public CallConference getCallConference()
{
return this.conference;
}
/**
* Returns whether or not the call is a video call.
*

Loading…
Cancel
Save