From b2f3e736726995c59373a52c7e0802e6b764a8df Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 2 Feb 2007 08:24:06 +0000 Subject: [PATCH] Don't make any btlib calls until the main form is up. This works around an (OS?) bug where, apparently, the confirm-turn-on-bt dialog eats pending events, including frmLoadEvent, so that the form never loads or is very broken if that dialog is allowed to come up too early. --- xwords4/palm/palmmain.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xwords4/palm/palmmain.c b/xwords4/palm/palmmain.c index ae15f2885..b2c57cc35 100644 --- a/xwords4/palm/palmmain.c +++ b/xwords4/palm/palmmain.c @@ -1317,7 +1317,9 @@ figureWaitTicks( PalmAppGlobals* globals ) /* XP_DEBUGF( "figureWaitTicks returning %d", result ); */ # ifdef XWFEATURE_BLUETOOTH - palm_bt_amendWaitTicks( globals, &result ); + if ( !!globals->mainForm ) { + palm_bt_amendWaitTicks( globals, &result ); + } # endif return result; @@ -1899,6 +1901,10 @@ initAndStartBoard( PalmAppGlobals* globals, XP_Bool newGame ) } #endif + if ( !!globals->game.comms ) { + comms_start( globals->game.comms ); + } + /* do this before drawing the board. If it assigns tiles, for example, that'll make a difference on the screen. */ (void)server_do( globals->game.server ); @@ -3731,8 +3737,13 @@ palm_send( const XP_U8* buf, XP_U16 len, #endif #ifdef XWFEATURE_BLUETOOTH case COMMS_CONN_BT: - result = palm_bt_send( buf, len, addr, btDataHandler, btConnHandler, - globals ); + if ( !!globals->mainForm ) { + result = palm_bt_send( buf, len, addr, btDataHandler, + btConnHandler, globals ); + if ( result < 0 ) { + userErrorFromStrId( globals, STR_BT_NOINIT ); + } + } break; #endif default: @@ -3828,6 +3839,7 @@ palm_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, # ifdef XWFEATURE_BLUETOOTH XP_Bool isBT = COMMS_CONN_BT == newAddr->conType; if ( !isBT ) { + XP_ASSERT( !!globals->mainForm ); palm_bt_close( globals ); showBTState( globals ); } @@ -3840,6 +3852,7 @@ palm_util_addrChange( XW_UtilCtxt* uc, const CommsAddrRec* oldAddr, # endif # ifdef XWFEATURE_BLUETOOTH } else if ( isBT ) { + XP_ASSERT( !!globals->mainForm ); if ( !palm_bt_init( globals, btDataHandler ) ) { userErrorFromStrId( globals, STR_BT_NOINIT ); }