From cc8738ee94d98bd4362dfe55809b9c55a090f67a Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 21:45:15 +0800 Subject: [PATCH 1/2] Simulator fix: After main loop, NSApplication needs to be terminated immediately. --- .../runtime-src/proj.ios_mac/mac/SimulatorApp.mm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm index f79e3924d2..7ef45ef4e9 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm +++ b/templates/lua-template-runtime/frameworks/runtime-src/proj.ios_mac/mac/SimulatorApp.mm @@ -41,9 +41,9 @@ using namespace cocos2d; -bool g_landscape=false; -CCSize g_screenSize; -GLView* g_eglView=NULL; +bool g_landscape = false; +cocos2d::Size g_screenSize; +GLView* g_eglView = nullptr; using namespace std; using namespace cocos2d; @@ -54,7 +54,7 @@ using namespace cocos2d; -(void) dealloc { - CCDirector::sharedDirector()->end(); + Director::getInstance()->end(); [super dealloc]; } @@ -63,11 +63,11 @@ using namespace cocos2d; - (void) applicationDidFinishLaunching:(NSNotification *)aNotification { - AppDelegate app; [self createSimulator:[NSString stringWithUTF8String:"HelloLua"] viewWidth:960 viewHeight:640 factor:1.0]; - int ret = Application::getInstance()->run(); - + Application::getInstance()->run(); + // After run, application needs to be terminated immediately. + [NSApp terminate: self]; } From 77a8476c8078b66b02f87fd60b7f9d4684758a41 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 12 Mar 2014 21:45:57 +0800 Subject: [PATCH 2/2] GLView::end needs to release self. --- cocos/2d/platform/desktop/CCGLView.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cocos/2d/platform/desktop/CCGLView.cpp b/cocos/2d/platform/desktop/CCGLView.cpp index 1f140dafde..0b4dcc7e11 100644 --- a/cocos/2d/platform/desktop/CCGLView.cpp +++ b/cocos/2d/platform/desktop/CCGLView.cpp @@ -386,7 +386,8 @@ void GLView::end() glfwSetWindowShouldClose(_mainWindow,1); _mainWindow = nullptr; } - + // Release self. Otherwise, GLView could not be freed. + release(); } void GLView::swapBuffers()