diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index 5855c3025b..cbb84bc205 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -13,6 +13,7 @@ #import "cocoaPandaAppDelegate.h" #include "graphicsEngine.h" +#include "config_cocoadisplay.h" @implementation CocoaPandaAppDelegate @@ -33,12 +34,26 @@ - (BOOL)applicationShouldTerminate:(NSApplication *)app { if (cocoadisplay_cat.is_debug()) { cocoadisplay_cat.debug() - << "Received applicationShouldTerminate, closing all Cocoa windows\n"; + << "Received applicationShouldTerminate, requesting to close all Cocoa windows\n"; } - // Call performClose on all the windows. This should make ShowBase shut down. + // Ask all the windows whether they are OK to be closed. + bool should_close = true; for (NSWindow *window in [app windows]) { - [window performClose:nil]; + if (![[window delegate] windowShouldClose:window]) { + should_close = false; + } } + if (should_close) { + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "No window objected to close request, closing all windows\n"; + } + // If so (none of them fired a close request event), close them now. + for (NSWindow *window in [app windows]) { + [window close]; + } + } + // Give the application a chance to run its own cleanup functions. return FALSE; } diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm index dbbbe8e5b2..fe67c50c13 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm @@ -12,6 +12,7 @@ */ #import "cocoaPandaWindowDelegate.h" +#include "config_cocoadisplay.h" @implementation CocoaPandaWindowDelegate - (id) initWithGraphicsWindow:(CocoaGraphicsWindow*)window { diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 98c3a7c711..1894d72967 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -26,6 +26,7 @@ INLINE PT(Texture) Texture:: make_copy() const { PT(Texture) tex = make_copy_impl(); CDWriter cdata_tex(tex->_cycler, true); + cdata_tex->_render_to_texture = false; cdata_tex->inc_properties_modified(); cdata_tex->inc_image_modified(); return tex; diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 75c2502bde..a8562f317d 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -10819,6 +10819,7 @@ CData() { Texture::CData:: CData(const Texture::CData ©) { _num_mipmap_levels_read = 0; + _render_to_texture = copy._render_to_texture; do_assign(©);