diff --git a/Easy2D/Base/EApp.cpp b/Easy2D/Base/EApp.cpp index 8cb0da97..f8b7acc0 100644 --- a/Easy2D/Base/EApp.cpp +++ b/Easy2D/Base/EApp.cpp @@ -271,8 +271,6 @@ void e2d::EApp::run() // 关闭控制台 EApp::showConsole(false); - // 释放所有内存资源 - this->_free(); } void e2d::EApp::setFPS(UINT32 fps) @@ -581,14 +579,6 @@ void e2d::EApp::showWindow() ShowWindow(GetHWnd(), SW_SHOWNORMAL); } -void e2d::EApp::_free() -{ - // 删除图片缓存 - ETexture::clearCache(); - // 删除所有对象(包括所有场景、定时器、监听器、动画) - EObjectManager::clearAllObjects(); -} - void e2d::EApp::quit() { get()->m_bEnd = true; diff --git a/Easy2D/Easy2D.vcxproj b/Easy2D/Easy2D.vcxproj index 949eaf95..97b23fc5 100644 --- a/Easy2D/Easy2D.vcxproj +++ b/Easy2D/Easy2D.vcxproj @@ -101,7 +101,7 @@ Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true - EditAndContinue + None false @@ -146,7 +146,6 @@ NotUsing Level3 MaxSpeed - false true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true @@ -172,7 +171,6 @@ NotUsing Level3 MaxSpeed - true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true diff --git a/Easy2D/Manager/EObjectManager.cpp b/Easy2D/Manager/EObjectManager.cpp index 9414e5f7..c2059524 100644 --- a/Easy2D/Manager/EObjectManager.cpp +++ b/Easy2D/Manager/EObjectManager.cpp @@ -1,11 +1,11 @@ #include "..\etools.h" // EObjectManager 释放池的实现机制: -/// EObject 类中的引用计数(m_nRefCount)保证了指针的使用安全 -/// 它记录了对象被使用的次数,当计数为 0 时,EObjectManager 会自动释放这个对象 -/// 所有的 EObject 对象都应在被使用时(例如 Text 添加到了场景中) -/// 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数 -/// 让其自动释放 +// EObject 类中的引用计数(m_nRefCount)保证了指针的使用安全 +// 它记录了对象被使用的次数,当计数为 0 时,EObjectManager 会自动释放这个对象 +// 所有的 EObject 对象都应在被使用时(例如 Text 添加到了场景中) +// 调用 retain 函数保证该对象不被删除,并在不再使用时调用 release 函数 +// 让其自动释放 // 释放池容器 static e2d::EVector s_vPool; @@ -45,15 +45,6 @@ void e2d::EObjectManager::add(e2d::EObject * nptr) } } -void e2d::EObjectManager::clearAllObjects() -{ - for (const auto &obj : s_vPool) - { - delete obj; - } - s_vPool.clear(); -} - void e2d::EObjectManager::notifyFlush() { s_bNotifyed = true; diff --git a/Easy2D/Node/ENode.cpp b/Easy2D/Node/ENode.cpp index aad847b7..e3361016 100644 --- a/Easy2D/Node/ENode.cpp +++ b/Easy2D/Node/ENode.cpp @@ -39,6 +39,10 @@ e2d::ENode::~ENode() EMsgManager::_clearAllMouseListenersBindedWith(this); EMsgManager::_clearAllKeyboardListenersBindedWith(this); EActionManager::_clearAllActionsBindedWith(this); + for (auto child : m_vChildren) + { + SafeReleaseAndClear(&child); + } } void e2d::ENode::onEnter() diff --git a/Easy2D/ebase.h b/Easy2D/ebase.h index 5f460356..862f6985 100644 --- a/Easy2D/ebase.h +++ b/Easy2D/ebase.h @@ -184,9 +184,6 @@ protected: UINT32 height ); - // 释放所有内存资源 - void _free(); - // 窗口程序 static LRESULT CALLBACK WndProc( HWND hWnd, diff --git a/Easy2D/etools.h b/Easy2D/etools.h index 5b6cc869..89685f10 100644 --- a/Easy2D/etools.h +++ b/Easy2D/etools.h @@ -20,9 +20,6 @@ public: e2d::EObject * nptr ); - // 删除所有节点 - static void clearAllObjects(); - // 通知内存池刷新 static void notifyFlush();