I'm having a problem that appears to be unique to the Handspring 3.1 ROM as
included in the Visor. My app responds to sysAppLaunchCmdSystemReset by
reading the preferences, resetting some values, and storing the preferences.
The preferences are read into a structure that resides as a local variable
on the stack. The structure size is under 200 bytes, but the structure does
contain three small C++ class objects.
(Abbreviated code snippits follow my signature.)
Using the Handspring POSE and the Handspring OS 3.1 ROM, the
PrefGetAppPreferences() results in a stack overflow. POSE is then hosed in
a loop and must be restarted. On an actual device, a fatal error occurs,
resulting in a hard reset being necessary to recover.
I am using CW9 with Constructor 1.8. I have increased the "pref - Stack
Size" to 8192, as the app needs a larger stack when running. It is a
multisegment app, but all of the needed functions are in the first segment.
I have used this same sysAppLaunchCmdSystemReset handler in other apps, and
they work fine. The differences between the ones that work and this app I'm
having trouble with are:
(a) This app uses the C++ compiler; others use the C compiler
(b) This app uses C++ exception handling; others don't
(c) This app has used constructor to change the stack size; others don't
Unfortunately, I can't "undo" any of these differences as either a
short-term or long-term solution.
No problems with the Palm POSE and the Palm OS 3.1 ROM.
Any insights would be most appreciated.
Jeff
�
UInt32 PilotMain(UInt16 Cmd, MemPtr pLaunchData, UInt16 LaunchFlags)
{
Err error;
switch (Cmd)
{
case sysAppLaunchCmdSystemReset:
AppLaunchCmdSystemReset();
return errNone;
...
}
}
static void AppLaunchCmdSystemReset(void)
{
APP_PREFERENCES MyPrefs;
PrefsLoadPreferences(&MyPrefs);
PrefsResetState(&MyPrefs);
PrefsSavePreferences(&MyPrefs);
}
void PrefsLoadPreferences(APP_PREFERENCES * pAppPrefs)
{
UInt16 size = sizeof(APP_PREFERENCES);
Int16 version;
version = PrefGetAppPreferences(
APP_CREATOR_CODE,
0,
pAppPrefs,
&size,
true);
// Error checking eliminated for brevity of snippit
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/