Page 1 of 1

PB 6.20 : OpenWindow error with #PB_Any

Posted: Mon Mar 31, 2025 9:57 pm
by KarLKoX
Any window command wich use a window id returned by OpenWindow failed when #PB_Any is passed as the first parameter.

Uncomment SmartWindowRefresh or SetWindowColor to see the error with PB 6.20, both version (ASM and C Backend)
Runs fine with with PB 6.04

Code: Select all

Global main_window.l

  ;- KO with PB 6.20 (OK with PB 6.04)
  main_window = OpenWindow(#PB_Any, 0, 0, 220, 100, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  If main_window
    ;- KO with PB 6.20 (OK with PB 6.04)
    ;SmartWindowRefresh(main_window, #True)

    ;- KO with PB 6.20 (OK with PB 6.04)
    ;SetWindowColor(main_window, 0)

    ButtonGadget  (1, 10, 60, 200, 30, "Close")
   
   Repeat
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 1 
              CloseWindow(#PB_All)
              End  
         EndSelect
            
     EndSelect
   Until Event = #PB_Event_CloseWindow
 EndIf

This code runs fine with PB 6.20, both version (ASM and C Backend)

Code: Select all

Global main_window.l

  ;- OK with PB 6.20
  main_window = OpenWindow(0, 0, 0, 220, 100, "Example...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

  If main_window
    ;- OK with PB 6.20
    SmartWindowRefresh(0, #True)

    ;- OK with PB 6.20
    SetWindowColor(0, 0)

    ButtonGadget  (1, 10, 60, 200, 30, "Close")
   
   Repeat
     Event = WaitWindowEvent()
     
     Select Event
     
       Case #PB_Event_Gadget
         Select EventGadget()
           Case 1 
              CloseWindow(#PB_All)
              End  
         EndSelect
            
     EndSelect
   Until Event = #PB_Event_CloseWindow
 EndIf

// Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)

Re: PB 6.20 : OpenWindow error with #PB_Any

Posted: Mon Mar 31, 2025 10:11 pm
by Fred
If you are using x64 version you need to replace the .l with .i

Re: PB 6.20 : OpenWindow error with #PB_Any

Posted: Mon Mar 31, 2025 10:12 pm
by Quin
Change .l to .i, you're trying to store a 64-bit address in a 32-bit variable. You almost never notice the crash on 6.04 because PB was storing values in low memory registers, but 6.10 and beyond changed this for security reasons.
For the record, it's a good thing, as annoying as it can be to debug, it helps find bugs.
Edit: Fred was faster :oops:

Re: PB 6.20 : OpenWindow error with #PB_Any

Posted: Mon Mar 31, 2025 11:00 pm
by KarLKoX
Oh thank you ! :D
In fact, it was not easy to debug because of the ~10k lines of code :?