所有从 wxWindow 继承的类都会有个 wxWindow* parent 参数,这样它的父窗口可以通过 GetChildren() 方法获得所有的子窗口,
include/wx/window.h 行 537
wxWindowList& GetChildren() { return m_children; }
所以只要是继承的 wxWindow 的类都会在它的父窗口被删除时被父窗口释放,可以查看
src/common/wincmn.cpp 行 276
wxWindowBase::~wxWindowBase()
也就是只要保证最上层的父窗口被删除就不用去 delete。
像 wxImageList 这种类
wxImageList()
Default constructor.
wxImageList(int width, int height, const bool mask = true, int initialCount = 1)
Constructor specifying the image size, whether image masks should be created, and the initial size of the list.
在构造函数中没有 wxWindow* parent 参数就需要自己删除。
include/wx/window.h 行 537
wxWindowList& GetChildren() { return m_children; }
所以只要是继承的 wxWindow 的类都会在它的父窗口被删除时被父窗口释放,可以查看
src/common/wincmn.cpp 行 276
wxWindowBase::~wxWindowBase()
也就是只要保证最上层的父窗口被删除就不用去 delete。
像 wxImageList 这种类
wxImageList()
Default constructor.
wxImageList(int width, int height, const bool mask = true, int initialCount = 1)
Constructor specifying the image size, whether image masks should be created, and the initial size of the list.
在构造函数中没有 wxWindow* parent 参数就需要自己删除。