Fix crash on restart when app had been exited with some form other

than main on top.  focusOwner was saved based on front form but on
startup I tried to set it in the main form.  This will need to be
merged into a branch based on the 4.2.1 release for a 4.2.1.
This commit is contained in:
ehouse 2007-12-08 21:04:44 +00:00
parent 693eeb6863
commit c72d0fec65
3 changed files with 34 additions and 15 deletions

View file

@ -466,7 +466,8 @@ positionBoard( PalmAppGlobals* globals )
PALM_GRIDLESS_SCORE_LEFT+2) * doubler; PALM_GRIDLESS_SCORE_LEFT+2) * doubler;
bounds.extent.x = (RECOMMENDED_SBAR_WIDTH + 2) * doubler; bounds.extent.x = (RECOMMENDED_SBAR_WIDTH + 2) * doubler;
bounds.extent.y = (PALM_GRIDLESS_SCORE_TOP - bounds.topLeft.y - 2) * doubler; bounds.extent.y = (PALM_GRIDLESS_SCORE_TOP - bounds.topLeft.y - 2)
* doubler;
} }
globals->progress.boundsRect = bounds; globals->progress.boundsRect = bounds;
#endif #endif
@ -1887,12 +1888,14 @@ drawFormButtons( PalmAppGlobals* globals )
if ( globals->hasTreoFiveWay ) { if ( globals->hasTreoFiveWay ) {
focusItem = globals->gState.focusItem; focusItem = globals->gState.focusItem;
if ( focusItem > 0 ) { if ( focusItem > 0 ) {
if ( isFormObject( globals->mainForm, focusItem ) ) {
/* XP_WARNF( "setting focus: %s", frmObjId_2str(focusItem) ); */ /* XP_WARNF( "setting focus: %s", frmObjId_2str(focusItem) ); */
setFormFocus( globals->mainForm, focusItem ); setFormFocus( globals->mainForm, focusItem );
if ( !isBoardObject( focusItem ) if ( !isBoardObject( focusItem )
&& buttonIsUsable( getActiveObjectPtr(focusItem) ) ) { && buttonIsUsable( getActiveObjectPtr(focusItem) ) ) {
drawFocusRingOnGadget( globals, focusItem, focusItem ); drawFocusRingOnGadget( globals, focusItem, focusItem );
} }
}
globals->gState.focusItem = -1; globals->gState.focusItem = -1;
} else { } else {
drawFocusRingOnGadget( globals, XW_MAIN_DONE_BUTTON_ID, drawFocusRingOnGadget( globals, XW_MAIN_DONE_BUTTON_ID,

View file

@ -55,9 +55,10 @@ MemPtr
getActiveObjectPtr( UInt16 objectID ) getActiveObjectPtr( UInt16 objectID )
{ {
FormPtr form = FrmGetActiveForm(); FormPtr form = FrmGetActiveForm();
XP_ASSERT( FrmGetObjectPtr( Int16 index = FrmGetObjectIndex( form, objectID );
form, FrmGetObjectIndex( form, objectID ) )!= NULL ); XP_ASSERT( index >= 0 );
return FrmGetObjectPtr( form, FrmGetObjectIndex( form, objectID ) ); XP_ASSERT( FrmGetObjectPtr( form, index )!= NULL );
return FrmGetObjectPtr( form, index );
} /* getActiveObjectPtr */ } /* getActiveObjectPtr */
/***************************************************************************** /*****************************************************************************
@ -67,7 +68,9 @@ void
getObjectBounds( UInt16 objectID, RectangleType* rectP ) getObjectBounds( UInt16 objectID, RectangleType* rectP )
{ {
FormPtr form = FrmGetActiveForm(); FormPtr form = FrmGetActiveForm();
FrmGetObjectBounds( form, FrmGetObjectIndex( form, objectID ), rectP ); Int16 index = FrmGetObjectIndex( form, objectID );
XP_ASSERT( index >= 0 );
FrmGetObjectBounds( form, index, rectP );
} /* getObjectBounds */ } /* getObjectBounds */
#if defined XW_FEATURE_UTILS #if defined XW_FEATURE_UTILS
@ -78,7 +81,9 @@ void
setObjectBounds( UInt16 objectID, RectangleType* rectP ) setObjectBounds( UInt16 objectID, RectangleType* rectP )
{ {
FormPtr form = FrmGetActiveForm(); FormPtr form = FrmGetActiveForm();
FrmSetObjectBounds( form, FrmGetObjectIndex( form, objectID ), rectP ); Int16 index = FrmGetObjectIndex( form, objectID );
XP_ASSERT( index >= 0 );
FrmSetObjectBounds( form, index, rectP );
} /* getObjectBounds */ } /* getObjectBounds */
/***************************************************************************** /*****************************************************************************
@ -172,7 +177,8 @@ void
centerControl( FormPtr form, UInt16 id ) centerControl( FormPtr form, UInt16 id )
{ {
RectangleType cBounds, fBounds; RectangleType cBounds, fBounds;
UInt16 index = FrmGetObjectIndex( form, id ); Int16 index = FrmGetObjectIndex( form, id );
XP_ASSERT( index >= 0 );
FrmGetObjectBounds( form, index, &cBounds ); FrmGetObjectBounds( form, index, &cBounds );
FrmGetFormBounds( form, &fBounds ); FrmGetFormBounds( form, &fBounds );
@ -423,9 +429,18 @@ getFocusOwner( void )
void void
setFormFocus( FormPtr form, XP_U16 objectID ) setFormFocus( FormPtr form, XP_U16 objectID )
{ {
FrmSetFocus( form, FrmGetObjectIndex( form, objectID ) ); Int16 index = FrmGetObjectIndex( form, objectID );
XP_ASSERT( index >= 0 );
FrmSetFocus( form, index );
} /* setFormFocus */ } /* setFormFocus */
XP_Bool
isFormObject( FormPtr form, XP_U16 objectID )
{
Int16 index = FrmGetObjectIndex( form, objectID );
return index >= 0;
}
#ifndef XW_TARGET_PNO #ifndef XW_TARGET_PNO
/* Warning: gross hack. HsNavDrawFocusRing doesn't work on newer Palms, /* Warning: gross hack. HsNavDrawFocusRing doesn't work on newer Palms,
e.g. Tungsten T. It's been replaced by FrmNavDrawFocusRing. But that e.g. Tungsten T. It's been replaced by FrmNavDrawFocusRing. But that

View file

@ -81,6 +81,7 @@ void drawOneGadget( UInt16 id, const char* text, Boolean hilite );
# ifdef XWFEATURE_FIVEWAY # ifdef XWFEATURE_FIVEWAY
XP_S16 getFocusOwner( void ); XP_S16 getFocusOwner( void );
void setFormFocus( FormPtr form, XP_U16 objectID ); void setFormFocus( FormPtr form, XP_U16 objectID );
XP_Bool isFormObject( FormPtr form, XP_U16 objectID );
void drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow, void drawFocusRingOnGadget( PalmAppGlobals* globals, XP_U16 idLow,
XP_U16 idHigh ); XP_U16 idHigh );
XP_Bool considerGadgetFocus( PalmAppGlobals* globals, const EventType* event, XP_Bool considerGadgetFocus( PalmAppGlobals* globals, const EventType* event,