On Thu, 03 Feb 2005 00:03:58 -0600, Logan Shaw <[EMAIL PROTECTED]> wrote:

AyloNs Hazzud wrote:
Err PrvMedindoPegaItem(void *tableP, Int16 row, Int16 column, Boolean
editable,
                            MemHandle *dataH, Int16 *dataOffset, Int16
*dataSize,
                            FieldPtr fld){
    FieldAttrType attr;
    Char * dataP;
    AnPiRecordPtr recordP;
    MemHandle recordH, fldH;

    /*Aproveita que a funÃÃo lida field a field e os configura*/
    FldGetAttributes(fld, &attr);
    attr.justification = rightAlign;
    attr.numeric = true;
    attr.singleLine = true;
    FldSetAttributes(fld, &attr);


FldSetMaxChars(fld, 6); *dataSize = FldGetMaxChars(fld) + 1; *dataOffset = 0;

    /*Retorna 1 se houver erro na alocaÃÃo da memÃria*/
    if (!(fldH = MemHandleNew(*dataSize)))
        return 1;

    recordH = DmQueryRecord(AnPiDB, CurrentRecord);
        ErrFatalDisplayIf(DmGetLastRecord(), "Record nÃo encontrado");

    recordP = MemHandleLock(recordH);

    dataP = (Char *) MemHandleLock(fldH);

    /*record->estado diz a medida atual*/
    FlpFToText(recordP->P[recordP->estado][row][column], dataP,
*dataSize -  1);

    MemHandleUnlock(fldH);
    MemHandleUnlock(recordH);

    *dataH = fldH;

    return 0;

}

Since you're getting read errors from 0x000000 and 0x000002 and since you have two pointers of type (Int16 *), it seems suspicious that maybe one of them is NULL. Have you tried validating all the arguments at the beginning of the function, like this:

        if (! tableP || ! dataH || ! dataOffset || ! dataSize || ! fld)
        {
            FrmCustomAlert (MyAlert, "NULL pointer passed", "", "");
            return 1;
        }

Also, it looks like you are storing a pointer (the "P" member
of the AnPiRecord) in a database.  That can be a bad idea.
Are you sure that after you read recordP that the pointer
recordP->P actually points anywhere?

You must be talking about this piece of code:

FlpFToText(recordP->P[recordP->estado][row][column], dataP,
*dataSize - 1);

This function reads the P member and write itÂs value (FlpCompDouble) in a especially formated text in dataP, which is a pointer to a locked MemHandle, Then, I assign this memhandle to the *data parameter.



Beyond that, my best advice is to step through this function in the debugger to establish exactly *which* line of code is accessing memory at 0x000000. That should at least tell you which pointer is invalid. (If you don't want to use the debugger, put a bunch of FrmCustomAlert()s in and then you have to click "OK" over and over again, and one time after you click "OK", the system will print its error message about invalid access to 0x000000. Then you know it's after the FrmCustomAlert() you just clicked "OK" for.)

  - Logan


IÂve already tried to debug in search of an pointer to Ox000000 being set in my function, but I cannot find it. Actually, this functions always run seamless, bothh anallowed access occurs when IÂm adding text to the field, more precisely in the ExpandFieldHeight function.


Here is a screenshot of my debugging section when exiting the function. I really cannot realize what IÂm doing wrong.

http://img226.exs.cx/img226/3047/screenshot0411go.jpg

All data is read and saved OK. In fact, in a actual device, It runs OK. The item style is narrowTextTableItem, and I have set its int field with TblSetItemInt.

Must I have to set any other fields before drawing the table? I want to left the pixels on the right blank, must I implement the drawprocedure or I can left it just as it is?

--
AyloNs Hazzud, com N invertido

Sempre usando Opera e seu fantÃstico programa de email, o M2. ComparaÃÃo do zoom do Opera com o do Firefox:
http://www.aylons.kit.net/2004/11/isso-sim-que-zoom.html


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

Reply via email to