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 );
}
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 * );
- (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;
/* 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 */
}
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;
}
}