Cocoa port :
authorDamien Plisson <damien.plisson@yahoo.fr>
Thu, 8 Oct 2009 15:28:31 +0000 (15:28 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Thu, 8 Oct 2009 15:28:31 +0000 (15:28 +0000)
Bug fix : newly created window not seen as activated by WM

Added more conservative memory management (may need to optimize later)

intern/ghost/intern/GHOST_SystemCocoa.mm
intern/ghost/intern/GHOST_WindowCocoa.mm

index fe3cd80f265543c10901f31240dd545ce6061979..94ed5c7c2ac701b74316f5f19be2c2dd87acb738 100644 (file)
@@ -806,7 +806,10 @@ GHOST_IWindow* GHOST_SystemCocoa::createWindow(
             GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
             m_windowManager->addWindow(window);
             m_windowManager->setActiveWindow(window);
-            pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
+                       //Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
+            pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
+                       pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
+
         }
         else {
                        GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n");
@@ -1156,7 +1159,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
     GHOST_IWindow* window = m_windowManager->getActiveWindow();
        
        if (!window) {
-               printf("\nM invalid window");
                return GHOST_kFailure;
        }
        
index 4d117d25df36dd0531dc38c14341b7b3fe23692e..a185aa036b1533d37d5b72354d5e04c3a06c72c4 100644 (file)
@@ -319,7 +319,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
        /*if(ugly_hack==m_windowRef) ugly_hack= NULL;
        
        if(ugly_hack==NULL) setDrawingContextType(GHOST_kDrawingContextTypeNone);*/
-    
+    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
        [m_openGLView release];
        
        if (m_window) {
@@ -327,6 +327,7 @@ GHOST_WindowCocoa::~GHOST_WindowCocoa()
                [m_window release];
                m_window = nil;
        }
+       [pool drain];
 }
 
 #pragma mark accessors
@@ -566,7 +567,9 @@ GHOST_TSuccess GHOST_WindowCocoa::swapBuffers()
 {
     if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
         if (m_openGLContext != nil) {
+                       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
                        [m_openGLContext flushBuffer];
+                       [pool drain];
             return GHOST_kSuccess;
         }
     }
@@ -577,7 +580,9 @@ GHOST_TSuccess GHOST_WindowCocoa::updateDrawingContext()
 {
        if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
                if (m_openGLContext != nil) {
+                       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
                        [m_openGLContext update];
+                       [pool drain];
                        return GHOST_kSuccess;
                }
        }
@@ -588,6 +593,8 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
 {
        if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
                if (m_openGLContext != nil) {
+                       NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+                       
                        [m_openGLContext makeCurrentContext];
 #ifdef GHOST_DRAW_CARBON_GUTTER
                        // Restrict drawing to non-gutter area
@@ -603,6 +610,7 @@ GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
                        };
                        GLboolean result = ::aglSetInteger(m_aglCtx, AGL_BUFFER_RECT, b);
 #endif //GHOST_DRAW_CARBON_GUTTER
+                       [pool drain];
                        return GHOST_kSuccess;
                }
        }