PB 6.20 : OpenWindow error with #PB_Any

Just starting out? Need help? Post your questions and find answers here.
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

PB 6.20 : OpenWindow error with #PB_Any

Post 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)
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 6.20 : OpenWindow error with #PB_Any

Post by Fred »

If you are using x64 version you need to replace the .l with .i
Quin
Addict
Addict
Posts: 1135
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

Re: PB 6.20 : OpenWindow error with #PB_Any

Post 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:
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Re: PB 6.20 : OpenWindow error with #PB_Any

Post by KarLKoX »

Oh thank you ! :D
In fact, it was not easy to debug because of the ~10k lines of code :?
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Post Reply