I just tried testing my application with the 4.0 ROMs, and I've hit an oddity
that's either a bug in 4.0 or my misunderstanding. I'm hoping someone can 
clue me in.

Here's the part of my application that's in question:

VoidHand nameRecHan = DmResizeRecord(gNameDB, recIdx, sizeof(NameInDB) + 
StrLen(newName));
if (nameRecHan) {
        NameInDBPtr nameRecPtr = MemHandleLock(nameRecHan);
        DmStrCopy(nameRecPtr, offsetof(NameInDB, projectName), newName);
        MemPtrUnlock(nameRecPtr);
        DmReleaseRecord(gNameDB, recIdx, true);
}

This worked fine in 3.5, but with 4.0, the emulator throws an error at the
call to DmReleaseRecord that the record is not busy. I've scoured the API
docs, and it does not explicitly say that DmResizeRecord sets the busy bit,
but I had thought that that was the case. Have I been mistaken all this time?
Given that DmResizeRecord returns a handle to the new record, it doesn't
really make sense to me that it wouldn't mark it busy. I mean, I would think
that the vast majority of the time, when you resize a record you're going to
want to write into it next.

The only way I've found to fix the above is to add a call to DmGetRecord
before the resize, in order to force the busy bit to be set, like this:

VoidHand nameRecHan = DmGetRecord(gNameDB, recIdx);
nameRecHan = DmResizeRecord(gNameDB, recIdx, sizeof(NameInDB) + StrLen(newName));
if (nameRecHan) {
        NameInDBPtr nameRecPtr = MemHandleLock(nameRecHan);
        DmStrCopy(nameRecPtr, offsetof(NameInDB, projectName), newName);
        MemPtrUnlock(nameRecPtr);
        DmReleaseRecord(gNameDB, recIdx, true);
}

But that seems like a wasted call.

So is DmResizeRecord supposed to set the busy bit, and this is really a bug
in 4.0, or have I been writing buggy code all this time and just got lucky
up until now? And if that's the case, is there a better way to do this than
to make that extraneous call to DmGetRecord?

Thanks,
--Jim Preston



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