From 1fb69dd2584712bad178162e8d3c2705ca9069a0 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 8 Jan 2012 00:39:41 -0500 Subject: [PATCH] Fixed bug 1303 - SDL_CreateFromWindow duplicates window (Cocoa only) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jens Köhler 2011-09-09 04:47:40 PDT When calling SDL_CreateWindowFrom with a NSWindow which already contains a NSView, the window will be duplicated because another NSView is added. I attached a possible fix that prevents the creation of a second NSView. --- src/video/cocoa/SDL_cocoawindow.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m index 423e17ca4..16f4b7d8c 100755 --- a/src/video/cocoa/SDL_cocoawindow.m +++ b/src/video/cocoa/SDL_cocoawindow.m @@ -526,9 +526,13 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created /* Fill in the SDL window with the window data */ { NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; - NSView *contentView = [[SDLView alloc] initWithFrame:rect]; - [nswindow setContentView: contentView]; - [contentView release]; + NSView *contentView = [ nswindow contentView ]; + /* Create view if not already exists */ + if (!contentView) { + contentView = [[SDLView alloc] initWithFrame:rect]; + [nswindow setContentView: contentView]; + [contentView release]; + } ConvertNSRect(&rect); window->x = (int)rect.origin.x;