diff options
author | dynaflash <[email protected]> | 2007-08-24 19:38:08 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-08-24 19:38:08 +0000 |
commit | 056b3e7f595b417c956b633ab20e79f6747aa70e (patch) | |
tree | 57e30194d58e50036ff97008701c67e30fc3b72a | |
parent | dddd220d43479ed9296a375b5b0e94848cd4096c (diff) |
MacGui: Fix main window closing to it doesnt crash HB and allow you to get it back. Also, closing main window now does NOT quit HandBrake.
- Courtesy of Ritsuka. Thanks Ritsuka!
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@864 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/hb.c | 12 | ||||
-rw-r--r-- | libhb/hb.h | 1 | ||||
-rw-r--r-- | macosx/Controller.mm | 16 |
3 files changed, 23 insertions, 6 deletions
diff --git a/libhb/hb.c b/libhb/hb.c index 4ffb62c85..57afabfbc 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -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 ); } diff --git a/libhb/hb.h b/libhb/hb.h index f1a369055..547718280 100644 --- a/libhb/hb.h +++ b/libhb/hb.h @@ -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 * ); diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 741a0448a..4e281b388 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -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; } } |