I have a custom load item function defined for a table.  It didn't work when
I expected it to.  I spent a lot of time debugging the function and finally
discovered it only works when I do something I didn't expect.

The table does not display anything UNLESS I include calls to MemHandleLock
and MemHandleUnlock.  Is there a side effect I don't understand?  Could I
have some sort of stack problem?  I hate having "magic" code so I'm hopefull
someone can explain.

As far as I can tell, the input to the function and the output from the
function are identical, but it only works if I call MemHandleLock and
MemHandleUnlock.

// snippet
Err CustomLoadItem(VoidPtr table,
                          Int16 row,
                          Int16 column,
                          Boolean editable,
                          MemHandle *hData,
                          Int16 *dataOffset,
                          Int16 *datasize,
                          FieldPtr fld)
{
   *hData = *GetColumn(RecIndexList[row].UniqueID,
                     column,
                     dataOffset,
                     datasize);

// when the following MemHandle calls are commented out, the table does not
display anything
// when they are compiled, the table displays as expected.
   MemHandleLock(*hData);
   MemHandleUnlock(*hData);

   return(0);
}
// end snippet

Thanks,
John Kelsey
www.tacits.com





-- 
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