Hi,

I just got started with Palm development. I had started before but had to
stop for time reasons. I've begun by developing a C++ framework for building
Palm programs. I'm using CodeWarrior 6 and Palm OS 3.0. So far I have
encapsulated the following objects :

Application Class
Form class
Table class
Database class

The table and form class is where my problems lie. I'm convinced I'm doing
something wrong. Basically, after I load the table and I begin to tap around
the screen moving focus from row to row I get the following errors in the
emulator. I don't what they are trying to tell me.

Field.c, Line 4787, Invalid Size
Field.c, Line 5939, Memory Reallocation Error

I get these errors without editing any values. Here is the load data
callback.

Err pcMainTable::LoadData( Word row, Word column, Boolean editable,
                           VoidHand *data, WordPtr dataOffset,
                           WordPtr dataSize, FieldPtr fld )
  {
  #pragma unused( row, column, editable, data, dataOffset, dataSize, fld )

        TablePtr table = ( TablePtr ) GetHandle();
        Word recordNum;

        FieldAttrType attr;

        // Get the record number that corresponds to the table item.
        // The record number is stored as the row id.
        recordNum = TblGetRowID( table, row );


        //recordH = DmQueryRecord( ToDoDB, recordNum );
        ErrFatalDisplayIf( !dataTable->GoTo( recordNum ), "Record not found");

        //recordH = DmQueryRecord( ToDoDB, recordNum );
        //ErrNonFatalDisplayIf( true, "This is a test, butthead !:g");

        // Find the Cell
        Word index = RCToCell( row, column );
        Word maxChars = 0;

        if ( index < 0 || index >= cellsInTable )
                return 0;

        if ( column == descriptionColumn )
                {

                maxChars = dataTable->GetFieldWidth( "NAME" );

                theRow = row;
                theCol = column;

                // Try to allocate enough storage for the field
                if ( !cellList[index].cellHandle )
                        if ( !AllocateCellStorage( index, maxChars + 1 ) )
                                return 0;

                #if defined( _ZTRACE )
                HostTraceOutputTL(appErrorClass, "Cell Handle for R%hu C%hu I%hu : 
H%lx",
                                                                                       
                                                                 row, column, index, 
cellList[index].cellHandle );
                #endif

                if ( !cellList[index].cellPtr )
                        cellList[index].cellPtr = MemHandleLock( 
cellList[index].cellHandle );

                // Now copy the data from the field into the cell
                dataTable->AsString( "NAME", (char *) cellList[index].cellPtr );

                // Unlock the string
                MemHandleUnlock( cellList[index].cellHandle );
                cellList[index].cellPtr = 0;

                // Now set the load data stuff
                *data = cellList[index].cellHandle;
                *dataOffset = 0;
                *dataSize = maxChars;
                }

        // Set the field to support auto-shift.
        if (fld)
                {
                FldGetAttributes(fld, &attr);
                attr.autoShift = true;
                FldSetAttributes(fld, &attr);
                FldSetMaxChars( fld, maxChars );
                }
  return 0;
  }


If I remove this code and replace it with :

Err pcMainTable::LoadData( Word row, Word column, Boolean editable,
                           VoidHand *data, WordPtr dataOffset,
                           WordPtr dataSize, FieldPtr fld )
  {
  #pragma unused( row, column, editable, data, dataOffset, dataSize, fld )


  *data = 0;
  *dataOffset = 0;
  *dataSize = 0;

  return 1;
  }

I get no errors, but then my rows aren't selectable either. I'm trying to
get my hands on the debug ROMs right now. It's possible that they might shed
more light on what's going on. I've used the Palm Reporter to check what I
can think of. I'm open to any and all suggestions.

Also, I should mention that if I just select the Continue button when I get
an error my program continues. No crashes. Any ideas ?


Eric


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to