Qt - #PB_Event_CloseWindow crash

Post bugreports for the Linux version here
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Qt - #PB_Event_CloseWindow crash

Post by wombats »

When closing the dialog with its close button, the program will often crash and report an IMA on the EndProcedure line of OnDialogClosed().

However, if the dialog is closed via the button, there is no crash.

Code: Select all

EnableExplicit

Global Quit, XML$, xml

Runtime Enumeration
  #Window
  #Dialog
  #DialogButton
EndEnumeration

Procedure OnWindowClosed()
  Quit = 1
EndProcedure

Procedure OnDialogClosed()
  FreeDialog(#Dialog)
  SetActiveWindow(#Window)
EndProcedure

Procedure OnDialogButtonClicked()
  PostEvent(#PB_Event_CloseWindow, DialogWindow(#Dialog), 0)
EndProcedure

XML$ = "<window id='#Dialog' name='TestDialog' text='test' minwidth='250' minheight='200' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"
XML$ + "  <vbox>"
XML$ + "    <button id='#DialogButton' text='OK' width='90' height='25'/>"
XML$ + "  </vbox>"
XML$ + "</window>"

If OpenWindow(#Window, 0, 0, 320, 240, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  xml = ParseXML(#PB_Any, XML$)
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, xml, "TestDialog", 0, 0, 0, 0, WindowID(#Window))
    
    BindEvent(#PB_Event_CloseWindow, @OnWindowClosed(), #Window)
    BindEvent(#PB_Event_CloseWindow, @OnDialogClosed(), DialogWindow(#Dialog))
    BindGadgetEvent(#DialogButton, @OnDialogButtonClicked())
    
    Repeat : WaitWindowEvent() : Until Quit = 1
    
  Else
    Debug DialogError(#Dialog)
  EndIf
  
EndIf
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Qt - #PB_Event_CloseWindow crash

Post by Fred »

I tried to reproduce it without success, can anybody else confirm ?
User avatar
mk-soft
Always Here
Always Here
Posts: 5334
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Qt - #PB_Event_CloseWindow crash

Post by mk-soft »

Tests QT:

VM: Ubuntu 18.04 LTS (X64) -> works
VM: Ubuntu 20.04 LTS (X64) -> crash

VM: Mint Linux 19 (X64) -> works
VM: Mint Linux 20 (X64) -> crash

VM Hostsystem: macOS Catalina (Parallels V16)
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
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Qt - #PB_Event_CloseWindow crash

Post by wombats »

This problem still exists, but I've found a workaround. Posting an event and freeing the dialog in the procedure linked to that event avoids the crash. The workaround isn't ideal, hoever, as the closing of the dialog can be delayed.

Code: Select all

EnableExplicit

Global Quit, XML$, xml

Enumeration #PB_Event_FirstCustomValue
  #CloseDialogEvent
EndEnumeration

Runtime Enumeration
  #Window
  #Dialog
  #DialogButton
EndEnumeration

Procedure OnWindowClosed()
  Quit = 1
EndProcedure

Procedure OnDialogClosed()
  PostEvent(#CloseDialogEvent, 0, 0, 0, #Dialog)
  SetActiveWindow(#Window)
EndProcedure

Procedure OnCloseDialogEvent()
  FreeDialog(EventData())
EndProcedure

Procedure OnDialogButtonClicked()
  PostEvent(#PB_Event_CloseWindow, DialogWindow(#Dialog), 0)
EndProcedure

XML$ = "<window id='#Dialog' name='TestDialog' text='test' minwidth='250' minheight='200' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"
XML$ + "  <vbox>"
XML$ + "    <button id='#DialogButton' text='OK' width='90' height='25'/>"
XML$ + "  </vbox>"
XML$ + "</window>"

If OpenWindow(#Window, 0, 0, 320, 240, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  BindEvent(#CloseDialogEvent, @OnCloseDialogEvent())
  
  xml = ParseXML(#PB_Any, XML$)
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, xml, "TestDialog", 0, 0, 0, 0, WindowID(#Window))
    
    BindEvent(#PB_Event_CloseWindow, @OnWindowClosed(), #Window)
    BindEvent(#PB_Event_CloseWindow, @OnDialogClosed(), DialogWindow(#Dialog))
    BindGadgetEvent(#DialogButton, @OnDialogButtonClicked())
    
    Repeat : WaitWindowEvent() : Until Quit = 1
    
  Else
    Debug DialogError(#Dialog)
  EndIf
  
EndIf
User avatar
Kukulkan
Addict
Addict
Posts: 1352
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: Qt - #PB_Event_CloseWindow crash

Post by Kukulkan »

I have the same :-(

(PB 6.01, x64, Ubuntu 20.04)
Post Reply