fix #763.
authorincastrix <incastrix>
Mon, 23 Mar 2009 21:15:52 +0000 (21:15 +0000)
committerincastrix <incastrix>
Mon, 23 Mar 2009 21:15:52 +0000 (21:15 +0000)
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java

index 36b4569..06064eb 100644 (file)
@@ -600,24 +600,31 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
        }
        
        public void handleProxyEvent(XDebugConnection connection) {
-               setDebugConnection(connection);
                //System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
                
-               fThread = new XDebugThread(this);
-               fThreads = new IThread[] {fThread};
-               fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
-               try {
-                       started();
-               } catch( DebugException e ){
-                       e.printStackTrace();            
-               }               
+               if (setDebugConnection(connection)) {
+                       fThread = new XDebugThread(this);
+                       fThreads = new IThread[] {fThread};
+                       fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
+                       try {
+                               started();
+                       } catch( DebugException e ){
+                               e.printStackTrace();            
+                       }
+               }
        }
 
-       private void setDebugConnection(XDebugConnection connection) {
-               if (connection != null) {
+       private boolean setDebugConnection(XDebugConnection connection) {
+               if (connection != null && fDebugConnection == null) {
                        fDebugConnection = connection;
                        fResponseListener = new ResponseListener(connection);
                        startListener();
+                       
+                       return true;
+               } else {
+                       connection.close();
+                       
+                       return false;
                }
        }