OSDN Git Service

MacGui: Fix main window closing to it doesnt crash HB and allow you to get it back...
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 24 Aug 2007 19:38:08 +0000 (19:38 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 24 Aug 2007 19:38:08 +0000 (19:38 +0000)
- Courtesy of Ritsuka. Thanks Ritsuka!

git-svn-id: svn://localhost/HandBrake/trunk@864 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb.c
libhb/hb.h
macosx/Controller.mm

index 4ffb62c..57afabf 100644 (file)
@@ -852,7 +852,17 @@ void hb_get_state( hb_handle_t * h, hb_state_t * s )
     hb_lock( h->state_lock );
 
     memcpy( s, &h->state, sizeof( hb_state_t ) );
-    h->state.state = HB_STATE_IDLE;
+    if ( h->state.state == HB_STATE_SCANDONE || h->state.state == HB_STATE_WORKDONE )
+        h->state.state = HB_STATE_IDLE;
+
+    hb_unlock( h->state_lock );
+}
+
+void hb_get_state2( hb_handle_t * h, hb_state_t * s )
+{
+    hb_lock( h->state_lock );
+
+    memcpy( s, &h->state, sizeof( hb_state_t ) );
 
     hb_unlock( h->state_lock );
 }
index f1a3690..5477182 100644 (file)
@@ -94,6 +94,7 @@ void          hb_stop( hb_handle_t * );
    Should be regularly called by the UI (like 5 or 10 times a second).
    Look at test/test.c to see how to use it. */
 void hb_get_state( hb_handle_t *, hb_state_t * );
+void hb_get_state2( hb_handle_t *, hb_state_t * );
 /* hb_get_scancount() is called by the MacGui in UpdateUI to 
    check for a new scan during HB_STATE_WORKING phase  */
 int hb_get_scancount( hb_handle_t * );
index 741a044..4e281b3 100644 (file)
@@ -111,7 +111,9 @@ static NSString*       ChooseSourceIdentifier   = @"Choose Source Item Identifie
 - (NSApplicationTerminateReply) applicationShouldTerminate:
     (NSApplication *) app
 {
-    if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )
+     hb_state_t s;
+    hb_get_state2( fHandle, &s );
+    if ( s.state ==  HB_STATE_WORKING)    
     {
         [self Cancel: NULL];
         return NSTerminateCancel;
@@ -1157,7 +1159,7 @@ list = hb_get_titles( fHandle );
 
        /* See if we are currently running */
        hb_state_t s;
-       hb_get_state( fHandle, &s );
+    hb_get_state2( fHandle, &s );
        if ( s.state ==  HB_STATE_WORKING)
        {
           /* If we are running, leave in memory when closing main window */
@@ -1167,9 +1169,13 @@ list = hb_get_titles( fHandle );
        }
        else
        {
-               /* Stop the application when the user closes the window */
-               [NSApp terminate: self];
-               return YES;
+               /* If we are running, leave in memory when closing main window */
+          [fWindow setReleasedWhenClosed: NO];
+          return YES;
+        
+        /* Stop the application when the user closes the window */
+               //[NSApp terminate: self];
+               //return YES;
        }
        
 }