[Not a bug] CloseWindow/Canvas - Invalid Memory Access PB573

Mac OSX specific forum
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

[Not a bug] CloseWindow/Canvas - Invalid Memory Access PB573

Post by Saki »

PB573 Big Sur - CloseWindow/Canvas Crash

Hi,
Maybe you can clarify it.
In the new rolling clock code, if I close the windows and don't remove the canvas with FreeGadget first there is a crash.
"Invalid memory access".
It is a small code and the lines are marked, there are only two of which one is relevant to trigger the crash.
Last edited by Saki on Sat Mar 27, 2021 1:41 pm, edited 1 time in total.
地球上の平和
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by mk-soft »

Your information is very helpful.

Which code? I assume the game counter?
Where is what marked?
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by Saki »

Hi
Get the module, this is the first code

Add the clock code, this is the second code

Search in the clock code this both lines : FreeGadget(canvas_ID) ; Mac need this or it crash PB573

Start the clock - Use close window - So you get the clock without menu - klick the clock - bang

The behavior is then the same as if the menu is not closed before closing the window

viewtopic.php?f=12&t=76880
地球上の平和
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by TI-994A »

Saki wrote:...if I close the windows and don't remove the canvas with FreeGadget first there is a crash.
This should not be necessary because all gadgets and resources associated with the window are automatically freed when the window is closed. There must be some reference to some resource of the closed window that's causing the IMA error.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by Saki »

Hi, that's exactly it.
It works under Linux, but the drop down menus are also not released under Linux either, which also leads to an gtk error message.
Under gtk2 and qt it is OK, under gtk3 it is not.
On Windows all is OK.

So there are several construction sites to report at once...

If you want to report it would be good, otherwise I'll do it when I have some more time (And feel like it).
地球上の平和
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by TI-994A »

Saki wrote:...the drop down menus are also not released under Linux either, which also leads to an gtk error...
Here's a reduced version of the code, and it appears to work on all three platforms without the need of freeing up the menu or canvas gadget:

Code: Select all

Global window_ID, canvas_ID, menu

Procedure CreateWindow(wFlags)
  wFlags | #PB_Window_ScreenCentered
  window_ID = OpenWindow(#PB_Any, 0, 0, 300, 150, "Canvas Test", wFlags)
  canvas_ID = CanvasGadget(#PB_Any, 0, 0, 300, 150)
  If wFlags & #PB_Window_SystemMenu
    menu = CreateMenu(#PB_Any, WindowID(window_ID))
    MenuTitle("Menu")
    MenuItem(1, "Quit")
  EndIf  
EndProcedure

wFlags = #PB_Window_SystemMenu
CreateWindow(wFlags)

Repeat
  
  Delay(10)
  
  Select WindowEvent()
      
    Case #PB_Event_CloseWindow 
      PostEvent(#PB_Event_Gadget, window_ID, canvas_ID, #PB_EventType_LeftButtonDown)
      
    Case #PB_Event_Menu
      If EventMenu() = 1
        appQuit = #True
      EndIf
      
    Case #PB_Event_Gadget
      Select EventGadget()
          
        Case canvas_ID 
          If EventType() = #PB_EventType_LeftButtonDown
            
            CloseWindow(window_ID)
            
            If wFlags = #PB_Window_BorderLess
              wFlags = #PB_Window_SystemMenu
            Else
              wFlags = #PB_Window_BorderLess
            EndIf
            
            CreateWindow(wFlags)
            
          EndIf
          
      EndSelect
      
  EndSelect
  
Until appQuit
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by Saki »

Nice.
Please report it.
Together we simply achieve more than alone, thank you.
地球上の平和
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by TI-994A »

TI-994A wrote:...it appears to work on all three platforms without the need of freeing up the menu or canvas gadget.
Saki wrote:Please report it.
:?:
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
User avatar
Saki
Addict
Addict
Posts: 830
Joined: Sun Apr 05, 2020 11:28 am
Location: Pandora

Re: CloseWindow/Canvas - Invalid Memory Access PB573

Post by Saki »

Hi,
sorry, I misunderstood.
Then the matter is clear, it is due to my VMwarePlayer.
That's why I always inquire about these things first, if a misconduct can be confirmed.

Since most use Linux VM, it is still very relevant to consider this.
地球上の平和
Post Reply