控件dispose后不能再调用其任何方法

    技术2025-10-15  5

     当一个控件被dispose后(即widget.isDispose返回为true时),调用该控件的任何方法,都将报异常:org.eclipse.swt.SWTException: Widget is disposed

    当然,在内存中,控件对应的对象仍然是存在的,并且只要它被引用,垃圾回收器就不会去回收它。文档说明: * Returns true if the widget has been disposed, * and false otherwise. * This method gets the dispose state for the widget. * When a widget has been disposed, it is an error to * invoke any other method using the widget.

    最新回复(0)