Fixed a potential Cocoa crash when closing a window

This commit is contained in:
Lior Halphon 2019-07-19 15:50:36 +03:00
parent 9651f2bb6b
commit f0809a667f
2 changed files with 2 additions and 0 deletions

View File

@ -389,6 +389,7 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample)
- (void)dealloc
{
[cameraSession stopRunning];
self.view.gb = NULL;
GB_free(&gb);
if (cameraImage) {
CVBufferRelease(cameraImage);

View File

@ -131,6 +131,7 @@ static const vector_float2 rect[] =
- (void)drawInMTKView:(nonnull MTKView *)view
{
if (!(view.window.occlusionState & NSWindowOcclusionStateVisible)) return;
if (!self.gb) return;
if (texture.width != GB_get_screen_width(self.gb) ||
texture.height != GB_get_screen_height(self.gb)) {
[self allocateTextures];