[EMAIL PROTECTED] wrote:
> > SysGetStackInfo returns the start and end of stacks as setup by app prefs. As
> > you can see from my code, I setup the app prefs.
> > Thus, from what I can see, my code should work.
>
> Sorry. I didn't examine your posted code closely (OK...at all).
No worries.
> > I was under the impression that the pref#0 resource is not available for
> > PalmOS 2.
>
> True. But neither is the Notification Manager on OS 2, and that's apparently
> what's causing your problem (TimSetSeconds sends out notification of the change,
> and it's the Notification Manager that's complaining about the stack). So on
> any OS that has the Notification Manager, you have the ability to change the
> stack via the 'pref'(0) resource.
Well, its actually more of a problem than just the Notification Manager which in fact
can occur under PalmOS 2. If your app
receives a notification and there isn't much stack to play with, things can go (and
have gone) horribly wrong. Unfortunately
PalmOS isn't very good about guaranteeing stack space to notification handlers. In
fact, it doesn't do anything about this at all.
Thus, to minimise the risk of some other app showing your app up, its best to create a
more manageable scenario i.e. create a
stack.
I've harped on a lot about stacks and application/data integration to Palm before so
I'll stop here. :-)
For those interested, the previous post of code to call TimSetSeconds with a new stack
had a problem with restoring the app info
properly. The following works well:
*****
#pragma stack_cleanup on
void Teenee::TimSetSecondsWithNewStack(ULong inSetSeconds) Throw_()
{
/*
* Ensure that the param is register based and not on the stack given that the stack
* will be unreferencable shortly.
*/
register ULong thePassedInSeconds = inSetSeconds;
/*
* Allocate a new stack and continue if we're successful.
*/
const int theNewStackSize = 2.5 * 1024;
register Ptr theNewStackStartP = static_cast<Ptr>(::MemPtrNew(theNewStackSize));
if (theNewStackStartP)
{
/*
* Calculate the end of the stack (the top) and initialise it with something
* that PalmOS wants to see.
*/
Ptr theNewStackEndP = theNewStackStartP + (theNewStackSize - sizeof(long));
::MemSet(theNewStackStartP, theNewStackSize, 0xFE);
/*
* If we're OS 3 or more then we must preserve app preferences given that checks
* against the stack pointers are made by some OS functions.
*/
DWord theRomVersion = 0;
::FtrGet(sysFtrCreator, sysFtrNumROMVersion, &theRomVersion);
register bool theOSIsV3 = (theRomVersion >= sysMakeROMVersion(3, 0, 0, 0, 0));
register SysAppInfoPtr theAppInfoP;
register Ptr theOldStackStartP;
register Ptr theOldStackEndP;
if (theOSIsV3)
{
SysAppInfoPtr theUnusedAppInfoP;
theAppInfoP = ::SysGetAppInfo(
&theUnusedAppInfoP,
&theUnusedAppInfoP
);
if (!theAppInfoP->stackP)
theAppInfoP = theAppInfoP->rootP;
// If we don't have a stack then we're using our parents.
theOldStackStartP = theAppInfoP->stackP;
theAppInfoP->stackP = theNewStackStartP;
theOldStackEndP = theAppInfoP->stackEndP;
theAppInfoP->stackEndP = theNewStackEndP;
}
/*
* Assign the new stack
*/
register Ptr theOldA7P = static_cast<Ptr>(SetA7(theNewStackEndP));
/*
* Do what we came to do
*/
::TimSetSeconds(thePassedInSeconds);
/*
* Restore our world and free the stack that we created
*/
SetA7(theOldA7P);
if (theOSIsV3)
{
theAppInfoP->stackP = theOldStackStartP;
theAppInfoP->stackEndP = theOldStackEndP;
}
::MemPtrFree(theNewStackStartP);
}
}
#pragma stack_cleanup reset
*****
Kind regards,
Christopher
--
Christopher Hunt
Class Action Pty. Ltd.
Complete time zone management for the Palm(tm) connected organizer.
Check out http://www.classactionpl.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html