Results 1 to 2 of 2

Thread: Trapping the RTE in Ui?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174

    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
    #InCaseOfRTE 
    ' do what has to be done
    #EndCaseOfRTE
    
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10
    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.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Members who have read this thread: 1

Posting Permissions

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