Here's a bit of a headscratcher that I thought was easy.. Have need of
tossing up a pacifier window while the system is off doing some other stuff,
then clearing the window when it's done. There are a number of places in
the app that we may need to do something that'll take between one and ten
seconds, so it's always polite to throw something up to let the user know
you're not ignoring them. To make this easier, I created a simple class
with the idea that instantiating one of these on the stack would display the
pacifier window, which would clear when the object is destructed. Since I
don't want to have to keep track of whether the pacifier is already
displayed or not, it keeps a counter internally and only displays/clears the
window if appropriate.
Now, the problem: Everything seems fine when I run the application for
whatever length of time I wish. When I fire up the beloved gremlins,
however, they run for a couple of minutes, and I start getting 'attempt to
read from unallocated memory' warnings from a couple calls below
EvtGetEvent.
All I have to do to make it stop complaining are comment out the
FrmDrawForm/FrmEraseForm calls - then gremlins run until I get bored and
shut it off. (Am still in development - the hardcore gremlin runs are yet
to come..) Very very odd, and I'm confused as hell. Thots?
--------- Somewhere in a header file -----
class PacifierWindow
{
public:
PacifierWindow();
~PacifierWindow();
private:
// Not allowed.
PacifierWindow(const PacifierWindow&);
static short ctr_;
static FormPtr wnd_;
};
--------- Somewhere in a source file -----
short PacifierWindow::ctr_ = 0;
FormPtr PacifierWindow::wnd_ = NULL;
PacifierWindow::PacifierWindow()
{
if(ctr_ == 0 && !wnd_)
{
wnd_ = FrmInitForm(ConnectionPacifierForm);
FrmDrawForm(wnd_);
}
ctr_++;
}
PacifierWindow::~PacifierWindow()
{
--ctr_;
if(!ctr_ && wnd_)
{
FrmEraseForm(wnd_);
FrmDeleteForm(wnd_);
wnd_ = NULL;
}
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/