diff -r 2455ef1f5bbc -r d5e927d5853b javauis/mmapi_akn/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java --- a/javauis/mmapi_akn/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java Wed Sep 01 12:33:18 2010 +0100 +++ b/javauis/mmapi_akn/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java Tue Sep 14 21:06:50 2010 +0300 @@ -33,6 +33,7 @@ import com.nokia.microedition.media.tone.PlayToneImpl; import com.nokia.microedition.volumekeys.ForegroundListener; import com.nokia.mj.impl.rt.support.Finalizer; +import com.nokia.mj.impl.utils.Logger; /** * ManagerImpl implements the functionality specified in @@ -56,6 +57,7 @@ private final ProtocolFactory iProtocolFactory = new ProtocolFactory(); private final ForegroundListener iForegroundListener; + private boolean iClosed = false; private Finalizer mFinalizer = new Finalizer() { public void finalizeImpl() @@ -166,6 +168,17 @@ iPlugIns.addElement(aPlugIn); } + private void checkClose() throws MediaException + { + if (iClosed) + { + MediaException me = new MediaException("MIDlet closed."); + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, + "Trying to create player when MIDlet is destroyed ", me); + throw me; + } + } + private void doFinalize() { if (mFinalizer != null) @@ -180,6 +193,7 @@ */ synchronized final void registeredFinalize() { + iClosed = true; _dispose(sEventSourceHandle); sEventSourceHandle = 0; } @@ -191,6 +205,7 @@ */ synchronized final void release() { + iClosed = true; _release(sEventSourceHandle); } @@ -348,9 +363,10 @@ /** * From PlugIn. */ - public InternalPlayer createPlayer(DataSource aSource) + public synchronized InternalPlayer createPlayer(DataSource aSource) throws MediaException, IOException { + checkClose(); InternalPlayer player = null; if (aSource.getContentType() != null) { @@ -424,9 +440,10 @@ * @exception SecurityException Thrown if the caller does not * have security permission to create the Player. */ - public Player createPlayer(String aLocator) + public synchronized Player createPlayer(String aLocator) throws IOException, MediaException { + checkClose(); if (aLocator == null) { throw new IllegalArgumentException("Locator is null."); @@ -519,9 +536,10 @@ * @exception SecurityException Thrown if the caller does not * have security permission to create the Player. */ - public Player createPlayer(InputStream aStream, String aType) + public synchronized Player createPlayer(InputStream aStream, String aType) throws IOException, MediaException { + checkClose(); if (aStream == null) { throw new IllegalArgumentException("InputStream is null.");