NetTalk Central

Author Topic: Dispose  (Read 4169 times)

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Dispose
« on: November 08, 2015, 06:23:30 PM »
Hi All,

I have added an invoice API to my app and as the invoice header relates to child records I have added a reference to those Q's

One of those Q's is a Files Q which holds a base64 encoded copy of a PDF of the invoice so there is a string reference to it.

I'm trying to dispose of these types as follows but I get a GPF.

    Loop I# = 1 TO Records(QInvoice)
        Get(QInvoice,I#)
        If ErrorCode()
            Break
        END
        DISPOSE(QInvoice.Files.File)
        DISPOSE(QINV:CostItem)
        DISPOSE(QINV:Files)
    END

If I remove         DISPOSE(QInvoice.Files.File)
it does not GPF but just hangs my web server.

Anyone know the correct way to use Dispose in this circumstance?

Cheers,

Kevin


[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Dispose
« Reply #1 on: November 10, 2015, 12:27:02 AM »
This line can GPF if Files is not set;

        DISPOSE(QInvoice.Files.File)

replace this line with

If not QInvoice.Files &= Null
        DISPOSE(QInvoice.Files.File)
End


Cheers
Bruce

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Dispose
« Reply #2 on: November 10, 2015, 05:11:24 PM »
Thanks for the suggestion Bruce but I'm still getting the GPF.

Edit:

Strangely I have similar code in my windows app that generates the Q's before XFiles converts them to XML and I post this to my web server and I'm not seeing the same problems there when disposing. Here is the code:

    Loop i# = 1 to Records(QInvoice)
        Get(QInvoice,i#)
        If Errorcode()
            Message('Unable to get QInvoice=' & i#)
            CYCLE
        END
        DISPOSE(QInvoice.File.EncodedFile)
        Dispose(QInv:CostItem)
        Dispose(QInv:File)
    END

My web app hangs on either of these lines if I move the order around:

        DISPOSE(QINV:CostItem)
        DISPOSE(QINV:Files)

and GPF's on

DISPOSE(QInvoice.File.EncodedFile)

At the moment I'm running the windows app and the web server on my dev machine
« Last Edit: November 10, 2015, 06:15:08 PM by kevin plummer »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Dispose
« Reply #3 on: November 10, 2015, 11:54:24 PM »
I guess I'd need to see an example to be sure Kevin.

>> and GPF's on
>> DISPOSE(QInvoice.File.EncodedFile)

If an "interim" value is null (ie in the above, File is an interim) then this sort of line will cause a GPF. (Hence the test in my last note.)

when adding a record to a queue you should set the pointers to all be explicitly null - they may not be cleared by default. If they are "just random" then you'll get issues when accessing, or disposing, those values.

cheers
Bruce