- fix Cocoa window setOrder function to maintain focus on a blender window (e.g....
authorDamien Plisson <damien.plisson@yahoo.fr>
Mon, 9 Nov 2009 17:06:48 +0000 (17:06 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Mon, 9 Nov 2009 17:06:48 +0000 (17:06 +0000)
- QuickTime export fixes.
Note that QuickTime export still crashes because it tries to open a "codec settings" dialog from the rendering background thread (and not the main/UI thread).
One quick fix may be to move the movie export initialization out of the render thread back into the operator function.
But a cleaner way would be to get rid of such a carbon/win32 dialog and place the codec settings inside blender interface
(additional fields in the output panel as it is currently the case for other file formats ?).

intern/ghost/intern/GHOST_WindowCocoa.mm
source/blender/quicktime/apple/quicktime_export.c
source/blender/quicktime/quicktime_export.h

index f0bc8dd4d0f8de6b41ba2808520313eff7ff92b2..6d6829f392534ee20822e9dcaef13e3efe0f67db 100644 (file)
@@ -684,10 +684,18 @@ GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
 {
        GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid")
     if (order == GHOST_kWindowOrderTop) {
-               [m_window orderFront:nil];
+               [m_window makeKeyAndOrderFront:nil];
     }
     else {
+               NSArray *windowsList;
+               
                [m_window orderBack:nil];
+               
+               //Check for other blender opened windows and make the frontmost key
+               windowsList = [NSApp orderedWindows];
+               if ([windowsList count]) {
+                       [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
+               }
     }
     return GHOST_kSuccess;
 }
index de8c41791329fd48c4077ce062717e1c4e049dce..a27279630329c5eac8615e11db3ca239365e9adc 100644 (file)
@@ -317,7 +317,7 @@ static void QT_StartAddVideoSamplesToMedia (const Rect *trackFrame, int rectx, i
                                                        k32ARGBPixelFormat,
                                                        trackFrame,
                                                        NULL, NULL, 0,
-                                                       (unsigned char *)qtexport->ibuf->rect,
+                                                       (Ptr)qtexport->ibuf->rect,
                                                        rectx * 4 );
        CheckError (err, "NewGWorldFromPtr error");
 
@@ -438,7 +438,7 @@ void makeqtstring (RenderData *rd, char *string) {
 }
 
 
-void start_qt(struct RenderData *rd, int rectx, int recty) {
+void start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty) {
        OSErr err = noErr;
 
        char name[2048];
@@ -460,7 +460,7 @@ void start_qt(struct RenderData *rd, int rectx, int recty) {
 
        qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeCodecDataExt");
 
-       if(rd->qtcodecdata == NULL && rd->qtcodecdata->cdParms == NULL) {
+       if(rd->qtcodecdata == NULL || rd->qtcodecdata->cdParms == NULL) {
                get_qtcodec_settings(rd);
        } else {
                qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType);
@@ -484,7 +484,7 @@ void start_qt(struct RenderData *rd, int rectx, int recty) {
                        /* do something? */
                }
                close(myFile);
-               err = FSPathMakeRef(theFullPath, &myRef, 0);
+               err = FSPathMakeRef((const UInt8 *)theFullPath, &myRef, 0);
                CheckError(err, "FsPathMakeRef error");
                err = FSGetCatalogInfo(&myRef, kFSCatInfoNone, NULL, NULL, &qtexport->theSpec, NULL);
                CheckError(err, "FsGetCatalogInfoRef error");
@@ -574,10 +574,13 @@ static void check_renderbutton_framerate(RenderData *rd)
        if( (rd->frs_sec == 24 || rd->frs_sec == 30 || rd->frs_sec == 60) &&
                (qtdata->gTemporalSettings.frameRate == 1571553 ||
                 qtdata->gTemporalSettings.frameRate == 1964113 ||
-                qtdata->gTemporalSettings.frameRate == 3928227)) {;} else
-       qtdata->gTemporalSettings.frameRate = 
-               (rd->frs_sec << 16) / rd->frs_sec_base ;
-
+                qtdata->gTemporalSettings.frameRate == 3928227)) {;} 
+       else {
+               if (rd->frs_sec_base > 0)
+                       qtdata->gTemporalSettings.frameRate = 
+                       (rd->frs_sec << 16) / rd->frs_sec_base ;
+       }
+       
        err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType,   &qtdata->gTemporalSettings);
        CheckError( err, "SCSetInfo error" );
 
@@ -634,7 +637,7 @@ int get_qtcodec_settings(RenderData *rd)
 
        check_renderbutton_framerate(rd);
 
-       // put up the dialog box
+       // put up the dialog box - it needs to be called from the main thread
        err = SCRequestSequenceSettings(qtdata->theComponent);
  
        if (err == scUserCancelled) {
index b5c0dcff2329097805604a6d6935131e6ff90ccb..4afcebab7bdd0d63607282f6c4b64a605bbf2bef 100644 (file)
@@ -36,7 +36,7 @@
 // quicktime movie output functions
 struct RenderData;
 
-void start_qt(struct RenderData *rd, int rectx, int recty);    //for movie handle (BKE writeavi.c now)
+void start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty);       //for movie handle (BKE writeavi.c now)
 void append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int recty);
 void end_qt(void);