On Mon, Nov 19, 2001 at 03:05:35PM -0600, Richard Bell wrote:
> I've got this down to the simplest case and hopefully someone knows
> something about this. What I'm doing is populating a form with controls
> based on settings in a database. The whole thing falls apart with
> successfully creating and destroying the controls when I allocate other
> memory structures. The problem is easy to duplicate just add the following
> code to a standard Palm OS Application Stationery (C++ application):
Richard, I'm using dynamic controls in my current project and haven't yet
seen the problem you are describing. However, I'm following your problem
with interest, because I want to see the solution, so I can avoid the
problem. :) I put the code you posted into a compilable source file and
do not see the problem you are describing. I tried to change as little of
your posted code as possible to get it to compile. Compiling with gcc
version 2.95.2-kgpd, and running on pose 3.3 with the 3.5 ez debug rom, I
have no trouble entering and exiting the app at will. What is the app
doing when it causes the reset? Are you not able to get a stack trace from
the debugger? Doesn't pose tell you something is wrong?
here are the files I used, I hope they are helpfull:
test.c
------------------------------------------------------------------
#include <PalmOS.h>
#include "resources.h"
static MemHandle TestHandle;
static void MainFormInit(FormPtr frmP)
{
FormLabelType *NewForm;
TestHandle = MemHandleNew(10);
NewForm= FrmNewLabel (&frmP,2000, "Test Label", 20, 20,stdFont);
FrmDrawForm(frmP);
}
Boolean MainFormHandleEvent(EventPtr e)
{
Boolean handled = false;
FormPtr frmP;
UInt16 obj1NDX;
Err error;
switch (e->eType)
{
case frmOpenEvent:
frmP = FrmGetActiveForm();
MainFormInit(frmP);
break;
case frmCloseEvent:
frmP = FrmGetActiveForm();
obj1NDX=FrmGetObjectIndex(frmP,2000);
if (obj1NDX != frmInvalidObjectId)
{
error=FrmRemoveObject (&frmP,obj1NDX);
}
MemHandleFree(TestHandle);
break;
default:
break;
}
return handled;
}
Boolean _handle_event(EventPtr e)
{
UInt16 formID;
FormPtr form;
switch(e->eType)
{
case frmLoadEvent:
formID = e->data.frmLoad.formID;
form = FrmInitForm(formID);
FrmSetActiveForm(form);
switch(formID)
{
case MainForm:
FrmSetEventHandler(form, MainFormHandleEvent);
break;
default:
ErrFatalDisplayIf(1, "Illegal Form Id");
break;
}
return true;
default:
break;
}
return false;
}/*_handle_event*/
void _event_loop(void)
{
EventType e;
UInt16 err;
do
{
EvtGetEvent(&e, evtWaitForever);
if (!SysHandleEvent(&e))
if (!MenuHandleEvent((void *)0, &e, &err))
if(!_handle_event(&e))
FrmDispatchEvent(&e);
} while (e.eType != appStopEvent);
}/*_event_loop*/
void _deinit_app(void)
{
FrmCloseAllForms();
return;
}/*_deinit_app*/
UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
{
switch(cmd)
{
case sysAppLaunchCmdNormalLaunch:
FrmGotoForm(MainForm);
_event_loop();
_deinit_app();
break;
default:
break;
}
return 0;
}/*PilotMain*/
--------------------------------------
resources.h
--------------------------------------
#define MainForm 1000
--------------------------------------
resources.h
--------------------------------------
#include "resources.h"
FORM ID MainForm AT (0 0 160 160)
NOFRAME
USABLE
BEGIN
END
scott
--
------------------------------------------------------------------------
scott [EMAIL PROTECTED]
------------------------------------------------------------------------
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/