Page 1 of 1

PB 6.20: My app crashes on Ubuntu 24.04.1

Posted: Mon Feb 24, 2025 6:49 am
by marcoagpinto
Heya,

After a year without using Linux, I have decided to install Ubuntu 24.04.1 and try PureBasic 6.20 on it with my app.

My app doesn't open the preferences window and crashes (stops responding or something).

Also, my app icon doesn't appear on the left toolbar of Ubuntu, but I have the old command:

Code: Select all

    ; Linux icon - 14/NOV/2014
    CompilerIf #PB_Compiler_OS=#PB_OS_Linux
      gtk_window_set_icon_(WindowID(#WINDOW_MAIN), ImageID(13))
    CompilerEndIf    
Here is the source-code of the app:
https://proofingtoolgui.org/_other/ptg4 ... 250224.zip

If someone is able to help, it would be great.

Thank you!

EDIT: I am using a VM for Ubuntu in VirtualBox

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

Re: PB 6.20: My app crashes on Ubuntu 24.04.1 (it is invisible window issue)

Posted: Thu Feb 27, 2025 8:09 pm
by marcoagpinto
Heya, @Fred,

A year ago, you wrote that on Ubuntu they changed the way of assyncronity in windows or something like that.

So, I came up with a trick that would only continue executing the code after the window was officially opened.

However, the invisible and not invisible window still gives very different values, and that is the reason my open-source tool doesn't work in Ubuntu and crashes.

Here is the example code:

Code: Select all

; Display a requester with an error message.
;
; To clean up the code
;
; V1.0 - 07/APR/2024
;
Procedure MessageRequesterError(MARCOAGPINTO_error_text$)
  
  MessageRequester("Error!",MARCOAGPINTO_error_text$,#PB_MessageRequester_Error)
  
EndProcedure





; Gets the maximum size a window can become in the desktop.
; (height)
;
; It opens an invisible full desktop window to find the value.
;
; 30/JUL/2024: Now asynchronous trick for Linux
;
;
; V1.0 - 14/AUG/2022
; V1.1 - 27/FEB/2024
;        o Use of flag: #PB_Window_MaximizeGadget
; V1.2 - 31/MAR/2024
;        o Check if temp window already exists, opening a message requester warning and exits the procedure with #False
; V1.3 - 30/JUL/2024
;        o Now asynchronous trick for Linux
;
Procedure GetMaxWindowDesktopHeight()
  
    MARCOAGPINTO_dynamic_value_for_window=3000
    
    ; Check if window already exists
    If IsWindow(MARCOAGPINTO_dynamic_value_for_window)=#True
      MessageRequesterError("Window number "+Str(MARCOAGPINTO_dynamic_value_for_window)+" already exists.")
      ProcedureReturn #False
    EndIf
    
    If OpenWindow(MARCOAGPINTO_dynamic_value_for_window,0,0,10,10,"Getting Maximum Window Size",#PB_Window_Maximize|#PB_Window_Invisible|#PB_Window_MaximizeGadget)=0
      MessageRequesterError("Can't open a window.")
      ProcedureReturn 0
    EndIf
    Repeat
      MARCOAGPINTO_event=WindowEvent()
    Until IsWindow(MARCOAGPINTO_dynamic_value_for_window)    
    MARCOAGPINTO_max_height=WindowHeight(MARCOAGPINTO_dynamic_value_for_window)
    CloseWindow(MARCOAGPINTO_dynamic_value_for_window)  
    
    ProcedureReturn MARCOAGPINTO_max_height
  
EndProcedure



; SAME PROCEDURE AS ABOVE BUT NOT WITH INVISIBLE WINDOW
Procedure GetMaxWindowDesktopHeight_not_invisible()
  
    MARCOAGPINTO_dynamic_value_for_window=3000
    
    ; Check if window already exists
    If IsWindow(MARCOAGPINTO_dynamic_value_for_window)=#True
      MessageRequesterError("Window number "+Str(MARCOAGPINTO_dynamic_value_for_window)+" already exists.")
      ProcedureReturn #False
    EndIf
    
    If OpenWindow(MARCOAGPINTO_dynamic_value_for_window,0,0,10,10,"Getting Maximum Window Size",#PB_Window_Maximize|#PB_Window_MaximizeGadget)=0
      MessageRequesterError("Can't open a window.")
      ProcedureReturn 0
    EndIf
    Repeat
      MARCOAGPINTO_event=WindowEvent()
    Until IsWindow(MARCOAGPINTO_dynamic_value_for_window)    
    MARCOAGPINTO_max_height=WindowHeight(MARCOAGPINTO_dynamic_value_for_window)
    CloseWindow(MARCOAGPINTO_dynamic_value_for_window)  
    
    ProcedureReturn MARCOAGPINTO_max_height
  
EndProcedure


Debug GetMaxWindowDesktopHeight()
Debug GetMaxWindowDesktopHeight_not_invisible()


Re: PB 6.20: My app crashes on Ubuntu 24.04.1

Posted: Sat Mar 01, 2025 9:05 pm
by infratec
Btw. this whole thing is something for coding questions and not for the bug section.

I downloaded your code and looked a bit inside ...

It would take a few days to bring it in a structure that I can work with.

You don't use EnableExplicit.
So how can you be sure that all your variables are used correct?

Nearly every variable is defined as Global.
So the posibilty of using them at wrong places is huge.

You use several event loops, which may/is working in windows, but in linux this results very often in broken programs.

If you make something which blocks your main code, you should use threads for this.

In my opinion the code needs a complete overhaul.

But, if I remember, I told you this already years ago.

Re: PB 6.20: My app crashes on Ubuntu 24.04.1

Posted: Sat Mar 01, 2025 9:12 pm
by marcoagpinto
infratec wrote: Sat Mar 01, 2025 9:05 pm Btw. this whole thing is something for coding questions and not for the bug section.

I downloaded your code and looked a bit inside ...

It would take a few days to bring it in a structure that I can work with.

You don't use EnableExplicit.
So how can you be sure that all your variables are used correct?

Nearly every variable is defined as Global.
So the posibilty of using them at wrong places is huge.

You use several event loops, which may/is working in windows, but in linux this results very often in broken programs.

If you make something which blocks your main code, you should use threads for this.

In my opinion the code needs a complete overhaul.

But, if I remember, I told you this already years ago.
heya,

I have been rewriting the code.

But my idea to solve the non-sincronity of opening windows in Ubuntu isn't working.

I created a loop that only exits when the window is opened so that I can get the right sizes of them, but it still gives wrong values... did you try the small code snippet I typed in my previous comment? It gives ridicule heights and that is why the preferences crash... they try to use negative values.