Results 1 to 2 of 2

Thread: Trapping the RTE in Ui?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Blog Entries
    Rep Power

    Trapping the RTE in Ui?

    Right now am in hospital so I can not try, but I look for a solution of the following:
    When I use getprop, setprop (win32-api) that allows to attach 4 bytes as a named property to anything that has a windows-handle I.e. hWnd, and my script causes a Runtime-Error, it leads to total crash of thinbasic since the properties are still attached to the automatically destroyed windows objects. Is there a way to either trap the RTE that would allow to use propRemove before the error is shown or could there be an udt-element similar to _Create or _Destroy that would get called in case of an RTE to all existing udts allowing to unbind hooks, attached properties, imagelists, icons etc. Just like
    Type tExample
    X as Long
    Function _Create()
    End Function
    Function _Destroy()
    End Function
    Function _RTEexit()
    ' here either a link to destroy or steps
    ' that have to be done in case
    ' of forced exit through Runtime-Error
    End function
    Thinkeable also as with a callback that is attached to a control that we had a directive - not udt'related as
    ' do what has to be done

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Milan - Italy
    Blog Entries
    Rep Power
    GPF (General Protection Fault) are that kind of errors trapped by the Windows operating system when a process try to read/write to a memory area not correctly handled.

    GPFs can occur for a huge number of possibilities.
    Mainly they happen when process read/write a memory area that has not been allocated or has been de-allocated or when a certain amount of memory is allocated but (for some reason) process try to read/write past the end of the allocated area.

    That is one of the biggest problem when writing software and using dynamic memory allocation.

    thinBasic Core engine keep track of its internal memory but also programmer (when allocating dynamic memory) must put in place solutions to avoid such situations.
    And in general Windows API do not check memory to see if it is valid or not. They rely on programmer ability.

    For example in this specific case ... instead of calling directly SetPropA or GetPropA you can wrap them in a function that checks if Windows handle is still valid using thinBasic IsWindow and act according.

    I will think if I find a way to trap something
    Last edited by ErosOlmi; 26-01-2022 at 19:50. | |
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts