Bug in PostEvent()?

Just starting out? Need help? Post your questions and find answers here.
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Bug in PostEvent()?

Post by tua »

Code: Select all

EnableExplicit

Enumeration Events #PB_Event_FirstCustomValue  
  #Event_Custom1
EndEnumeration  

Define EventID

Procedure ButtonClicked()
  Debug PostEvent(#Event_Custom1)
EndProcedure

If OpenWindow(0, 0, 0, 300, 100, "Bug? demo", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(1, 50, 50, 60, 30, "Click me")
  BindGadgetEvent(1, @ButtonClicked(), #PB_EventType_LeftClick)
  Repeat
    EventID = WaitWindowEvent() 
    Select EventID
      Case #Event_Custom1
        Debug "Custom1 event detected"
    EndSelect    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Every post attempt returns 0, yet quite a number of posts succeed according to the trap in the event loop - any ideas what's not working as designed here (Windows, PB 6.20)?
Little John
Addict
Addict
Posts: 4802
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Bug in PostEvent()?

Post by Little John »

No bug in PostEvent().

Never use WaitWindowEvent() more than once in an event loop!

Code: Select all

Until EventID = #PB_Event_CloseWindow
works as expected.
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: Bug in PostEvent()?

Post by tua »

While what you point out is certainly true (I just hastily pasted a demo together - my bad), it has nothing to do with the issue.

PostEvent succeeds, as can be seen by the events being trapped, yet it returns 0 = failure, when according to the documentation

Returns a non-zero value if the event was sent without error, zero otherwise.
Little John
Addict
Addict
Posts: 4802
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Bug in PostEvent()?

Post by Little John »

tua wrote: Sat Mar 01, 2025 4:50 pm PostEvent succeeds, as can be seen by the events being trapped, yet it returns 0 = failure
Yes, that's a contradiction to the documentation.
User avatar
mk-soft
Always Here
Always Here
Posts: 6315
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Bug in PostEvent()?

Post by mk-soft »

Is an bug under Windows. Under macOS and Linux it returns a 1 (True)

But I've never analysed it so far because it always works (if you don't do anything wrong)
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
Little John
Addict
Addict
Posts: 4802
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Bug in PostEvent()?

Post by Little John »

mk-soft wrote: Sat Mar 01, 2025 5:58 pm But I've never analysed it so far because it always works (if you don't do anything wrong)
Yep. ;-)
tua
User
User
Posts: 68
Joined: Sun Jul 23, 2023 8:49 pm
Location: BC, Canada

Re: Bug in PostEvent()?

Post by tua »

Thanks for confirming - will file a bug report (if one does not already exist).
Post Reply