"Chris Faherty" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thursday 31 March 2005 11:54, Lukas Zeller wrote:
>
> > Where did you copy this from? I believe I looked up DmAttachRecord
in
> > the most recent PalmOS docs and did not find the note about
passing a
> > NULL pointer. Anyway, documented or not, doing so reliably crashes
> > the new SPRINT Treo at next call to DmSyncDatabase().
>
> The PalmOS 3.5 sources, available by signing up somewhere years ago.
Not
> sure where to get it now, likely still available from one of the
Palm
> companies.
>
> Yeah hard to tell what's changed since 3.5. I looked at the
MemPtrResize()
> and I see that setting it to zero size is discouraged but not
illegal. Not
> sure of the ramifications of having a zero-size chunk connected to a
record
> versus no chunk at all.
>
> Really though I don't even think it's all that important, what size
the
> chunk is. You could probably just leave it as-is. Once the sync
process
> sees the delete attribute, the record will be removed.
>
> --
> /* Chris Faherty <[EMAIL PROTECTED]> */
>
Chris,
Unfortunately, size does matter. A deleted record with data implies an
archived record. Conduits may have to handle both deleted and archived
records. This whole thing is very unfortunate. Try to do the "right"
thing by the book and look where it gets you. Oy vei!
Anyway, I have tested the zero length chunk solution with
emulators/simulators and ROM versions from 3.5.1 to 5.4.x., including
previous version of Treo 650. It seems to work. Lukas has tested with
the latest Treo update so I guess that is the way we have to go.
I post the modified workaround below for those who want to use it.
Caveat Emptor all the way. Maybe the next 650 update will break this
too.
Lucas, did you try the 650 update without the delete workaround? Maybe
it is fixed?
static Err deleteRecordWorkAround(DmOpenRef dbP, UInt16 index) {
UInt16 attr;
Err err = errNone;
MemHandle h = DmResizeRecord(dbP, index, 0);
if(h) {
/* UInt32 hSize = MemHandleSize(h); // testing */
DmRecordInfo(dbP, index, &attr, NULL, NULL);
attr |= dmRecAttrDelete|dmRecAttrDirty;
DmSetRecordInfo(dbP, index, &attr, NULL);
}
else {
err = DmGetLastErr();
}
return err;
}
/**
* Delete or archive a record.
* @param dbP the database reference.
* @param index current sort index of the record.
* @param archive if true archive the record else delete it.
*/
void deleteRecord(DmOpenRef dbP, UInt16 index, Boolean archive) {
if (archive)
DmArchiveRecord(dbP, index);
else
// DmDeleteRecord(dbP, index);
deleteRecordWorkAround(dbP, index);
// Deleted records are stored at the end of the database.
DmMoveRecord(dbP, index, DmNumRecords(dbP));
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/