Quicktime Carbon: Fix memory leak when build with cocoa
[blender.git] / source / blender / quicktime / apple / quicktime_export.c
index dea170ddeb4806ff534c93f675e7e85e30aa313d..68fd60d89d2468d8b336e97734ead933fada339b 100644 (file)
@@ -783,7 +783,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
        err = SCRequestSequenceSettings(qtdata->theComponent);
  
        if (err == scUserCancelled) {
-               return 0;
+               return OPERATOR_FINISHED;
        }
 
                // update runtime codecsettings for use with the codec dialog
@@ -844,7 +844,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op)
                }
        }
 
-       return 1;
+       return OPERATOR_FINISHED;
 }
 
 static int ED_operator_setqtcodec(bContext *C)
@@ -852,6 +852,17 @@ static int ED_operator_setqtcodec(bContext *C)
        return G.have_quicktime != FALSE;
 }
 
+#if defined(__APPLE__) && defined(GHOST_COCOA)
+//Need to set up a Cocoa NSAutoReleasePool to avoid memory leak
+//And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that
+extern int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op);
+
+int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
+{
+       return request_qtcodec_settings(C, op);
+}
+#endif
+
 
 void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot)
 {
@@ -861,7 +872,11 @@ void SCENE_OT_render_data_set_quicktime_codec(wmOperatorType *ot)
     ot->idname= "SCENE_OT_render_data_set_quicktime_codec";
        
     /* api callbacks */
+#if defined(__APPLE__) && defined(GHOST_COCOA)
+       ot->exec = cocoa_request_qtcodec_settings;
+#else
     ot->exec= request_qtcodec_settings;
+#endif
     ot->poll= ED_operator_setqtcodec;
        
     /* flags */