Fix issues not disposing listeners in PNP launch wizard
authorEd Swartz <ed.swartz@nokia.com>
Thu, 08 Apr 2010 14:31:29 -0500
changeset 1184 745221c781a3
parent 1173 3356621aee34
child 1185 02373fb1e121
Fix issues not disposing listeners in PNP launch wizard
debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java	Wed Apr 07 14:48:51 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java	Thu Apr 08 14:31:29 2010 -0500
@@ -41,6 +41,8 @@
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.ControlAdapter;
 import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.graphics.FontMetrics;
@@ -118,6 +120,15 @@
 			}
 		});
 		manager.addConnectionListener(this);
+
+		parent.addDisposeListener(new DisposeListener() {
+			public void widgetDisposed(DisposeEvent e) {
+				manager.removeConnectionListener(ConnectToDeviceDialog.this);
+				
+				if (currentServiceListener != null)
+					currentServiceListener.removeStatusChangedListener(ConnectToDeviceDialog.this);
+			}
+		});
 		
 		final Composite buttonGroup = new Composite(viewerGroup, SWT.NONE);
 		int w = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_MARGIN);
@@ -323,12 +334,5 @@
 			}
 		});
 	}
-	
-	@Override
-	public boolean close() {
-		manager.addConnectionListener(this);
-		return super.close();
-	}
-
 }