PanelGadget-SplitterGadget Warning

Linux specific forum
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

PanelGadget-SplitterGadget Warning

Post by Guimauve »

Hello everyone,

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : PanelGadget-SplitterGadget Warning
; File Name : PanelGadget-SplitterGadget Warning.pb
; File version: 1.0.0
; Programming : Problem demonstration
; Programmed by : Guimauve
; Date : 24-02-2012
; Last Update : 24-02-2012
; PureBasic code : 4.61 Beta 1 x64
; Plat-form : LinuxMint12 x64 + Gnome-Shell
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Problem description :
;
; When we place a PanelGadget inside a SplitterGadget, we can't add gadget items to 
; the PanelGadget without receiving a GTK Warning :
;
; WARNING CRITICAL: clearlooks_style_draw_box_gap: assertion 'height >=-1' failed
;
; This also occur when Resize the window as small as possible. (Maybe a 
; WindowBounds() will avoid this problem but we can rely on this as a solution)
;
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Enumeration
  
  #MainWin
  
  #Panel_Sources
  #Editor_Log
  #Splitter_Sources_Log
  
  #Panel_Tools
  #Splitter_Sources_Log_Tools
  
EndEnumeration

Procedure ResizeEditorWindow()
  
  ResizeGadget(#Splitter_Sources_Log_Tools, #PB_Ignore, #PB_Ignore, WindowWidth(#MainWin) - 10, WindowHeight(#MainWin) - 10)
  
EndProcedure

If OpenWindow(#MainWin, 50, 50, 800, 600, "Panel and Splitter", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  
  PanelGadget(#Panel_Sources, 0, 0, 0, 0)
    AddGadgetItem(#Panel_Sources, 0, "Source 1")
    AddGadgetItem(#Panel_Sources, 1, "Source 2")
  CloseGadgetList()
  
  EditorGadget(#Editor_Log, 0, 0, 0, 0, #PB_Editor_ReadOnly)
  
  SplitterGadget(#Splitter_Sources_Log, 0, 0, 0, 0, #Panel_Sources, #Editor_Log)
  
  PanelGadget(#Panel_Tools, 0, 0, 0, 0)
    AddGadgetItem(#Panel_Tools, 0, "Outil 1")
    AddGadgetItem(#Panel_Tools, 1, "Outil 2")
  CloseGadgetList()
  
  SplitterGadget(#Splitter_Sources_Log_Tools, 5, 5, WindowWidth(#MainWin)-10, WindowHeight(#MainWin)-10, #Splitter_Sources_Log, #Panel_Tools, #PB_Splitter_Vertical)
  
  ; The following code is a workaround to avoid the GTK WARNING
  ; Of course, the AddGadgetItem() above should be deleted.
  
  ;   OpenGadgetList(#Panel_Sources)
  ;     AddGadgetItem(#Panel_Sources, 0, "Source 1")
  ;     AddGadgetItem(#Panel_Sources, 1, "Source 2")
  ;   CloseGadgetList()
  ;   
  ;   OpenGadgetList(#Panel_Tools)
  ;     AddGadgetItem(#Panel_Tools, 0, "Outil 1")
  ;     AddGadgetItem(#Panel_Tools, 1, "Outil 2")
  ;   CloseGadgetList()

  SetGadgetState(#Splitter_Sources_Log, WindowHeight(#MainWin) * 0.80)
  SetGadgetState(#Splitter_Sources_Log_Tools, WindowWidth(#MainWin) * 0.85)
  
  Repeat
    
    EventID = WaitWindowEvent()
    
    Select EventID
        
      Case #PB_Event_Menu
        
        Select EventMenu()
            
        EndSelect
        
      Case #PB_Event_Gadget
        
        Select EventGadget()
            
        EndSelect
        
      Case #PB_Event_SizeWindow, #PB_Event_RestoreWindow
        ResizeEditorWindow()
        
    EndSelect
    
  Until EventID = #PB_Event_CloseWindow
  
EndIf 

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Best regards
Guimauve
Ulix
User
User
Posts: 48
Joined: Wed Jan 23, 2008 12:45 pm
Location: France, Montpellier

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Ulix »

I tried your code, same warning! :oops:
I'm on Utuntu 10.04 (Lucid), 2.6.32.26 Generic Linux

Ulix :lol:
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by idle »

There seems to be a few gadgets that incorrectly report their width and heights as -1
If you connect a gadget signal to "size-allocate" you can get back the width height
in the callback but it may not be any use in this situation.

Code: Select all

Procedure AllocateSize(*wiget.GtkWidget,*allocation.GtkAllocation,*userdata)
  x = *allocation\x 
  y =  *allocation\y 
  width = *allocation\width
  height = *allocation\height
EndProcedure  

 g_signal_connect_(GadgetID(gadget),"size-allocate",@AllocateSize(),0);
Windows 11, Manjaro, Raspberry Pi OS
Image
Fred
Administrator
Administrator
Posts: 18154
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Fred »

Seems to work on on 4.70 on ubuntu 11.04 x64. Can anybody confirm ?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by ts-soft »

DebugOutput wrote:[18:05:37] Warte auf den Start des Executable...
[18:05:37] Executable-Typ: Linux - x64 (64bit)
[18:05:37] Executable gestartet.
[18:05:37] [WARNING] Zeile: 47
[18:05:37] [WARNING] CRITICAL: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
[18:05:37] [WARNING] Zeile: 51
[18:05:37] [WARNING] CRITICAL: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
[18:05:37] [WARNING] Zeile: 53
[18:05:37] [WARNING] CRITICAL: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
[18:05:37] [WARNING] Zeile: 56
[18:05:37] [WARNING] CRITICAL: clearlooks_style_draw_box_gap: assertion `height >= -1' failed
Ubuntu 12.04 (x64) with Gnome-Shell
PB 4.70 Beta 1
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Fred
Administrator
Administrator
Posts: 18154
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Fred »

Sounds like a warning theme bug: https://bugs.launchpad.net/ubuntu/+sour ... bug/538499

Does it crashes the IDE ?
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Guimauve »

Fred wrote:Sounds like a warning theme bug: https://bugs.launchpad.net/ubuntu/+sour ... bug/538499

Does it crashes the IDE ?
Nope, the IDE don't crash but if this bug is on the GTK side can we do something about it ?

PB V4.70 Beta 1 x64
LinuxMint 13 x64 + Gnome-Shell 3.4.2

Best regards
Guimauve
Fred
Administrator
Administrator
Posts: 18154
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Fred »

As you can see, many apps are affected, so i don't know what I can do for this.
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Re: PB4.61B1 - PanelGadget-SplitterGadget Warning

Post by Guimauve »

Fred wrote:As you can see, many apps are affected, so i don't know what I can do for this.
And this bug as been reported in march 2010 and nothing happen on Ubuntu side. Since the compiled program don't crash and we can't do anything about it, I think we should leave this problem as is but keep an eye on it in the future.

Maybe contacting Ubuntu Development Team and ask them why nothing happen for more than 2 years about this bug.

Best regards
Guimauve
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: PanelGadget-SplitterGadget Warning

Post by BorisTheOld »

We're still finding it impossible to place a PanelGadget on a SplitterGadget without GTK warnings occurring and the program hanging. Here's some typical output.

Code: Select all

[23:10:38] Executable type: Linux - x86  (32bit)
[23:10:38] Executable started.
[23:10:42] [WARNING] clsFrame.pbi (Line: 197)
[23:10:42] [WARNING] GLib-GObject (WARNING): invalid cast from `GtkNotebook' to `GtkFixed'
[23:10:42] [WARNING] clsFrame.pbi (Line: 197)
[23:10:42] [WARNING] Gtk (CRITICAL): IA__gtk_fixed_put: assertion `GTK_IS_FIXED (fixed)' failed
[23:10:42] [WARNING] clsFrame.pbi (Line: 197)
[23:10:42] [WARNING] Gtk (CRITICAL): IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
[23:11:33] The debugged executable quit unexpectedly.
We use two Containers attached to the Splitter. Everything works fine, even for very complex layouts, until we add a Panel. As soon as we add it the application dies.

As a result of these difficulties, we now avoid using a Panel on a Splitter. Instead, we simulate a Panel using Containers and Buttons. Or we avoid using the Splitter so that we can use a regular Panel.

Ubuntu 12.04 LTS x86, PB 5.00 & 5.10b1
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
lakomet
User
User
Posts: 53
Joined: Mon Apr 04, 2011 3:56 am
Location: Russia,Angarsk

Re: PanelGadget-SplitterGadget Warning

Post by lakomet »

BorisTheOld wrote:We're still finding it impossible to place a PanelGadget on a SplitterGadget without GTK warnings occurring and the program hanging.
LinuxMint 13(Mate) x86, 5.10b1 - there are no warnings, everything works.
Linux Mint Maya(Mate), x86, PureBasic 5.00(5.10b1)
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: PanelGadget-SplitterGadget Warning

Post by BorisTheOld »

It's been a couple of years since we encountered the problem shown in the example given by Guimauve. And if you run the example today the problem still shows up. But last night I thought I'd take another look at it, and I think I've discovered exactly what is happening.

It's all to do with Splitter events.

In some tests on our own code, I found the following:

For Linux, two Splitter events are generated during the creation of the Splitter. During the first, the attached panels still show zero length for width and height. However, during the second Splitter event, the panels show their operating sizes. What I've found is that gadgets should not be added until after the second Splitter event has been completed. That's why Guimauve's workaround works.

GTK seems to have problems working with those zero length sizes until that second Splitter event has completed. Interestingly, under Linux the Splitter will not issue any more events after those first two until the splitter bar is moved. And under Windows, those first two events never occur during the creation process.

This morning I made some minor changes to our Splitter class to delay the attachment of items to the panels, and the problem has gone away.
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PanelGadget-SplitterGadget Warning

Post by idle »

It needs to be connected to a size-allocate signal
otherwise you would or should get -1 for width and height
Windows 11, Manjaro, Raspberry Pi OS
Image
BorisTheOld
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Apr 24, 2012 5:08 pm
Location: Ontario, Canada

Re: PanelGadget-SplitterGadget Warning

Post by BorisTheOld »

Unfortunately, the Splitter documentation quite specifically says that sizes do not need to be specified, and that the gadgets will be automatically sized.

Code: Select all

  If OpenWindow(0, 0, 0, 230, 180, "SplitterGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    #Button1  = 0
    #Button2  = 1
    #Splitter = 2
    ButtonGadget(#Button1, 0, 0, 0, 0, "Button 1") ; No need to specify size or coordiantes
    ButtonGadget(#Button2, 0, 0, 0, 0, "Button 2") ; as they will be sized automatically
    SplitterGadget(#Splitter, 5, 5, 220, 120, #Button1, #Button2, #PB_Splitter_Separator)
    TextGadget(3, 10, 135, 210, 40, "Above GUI part shows two automatically resizing buttons inside the 220x120 SplitterGadget area.",#PB_Text_Center )
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
This is true for Windows. It also seems to be true for Linux except for when a Panel is attached.

Two years ago, when I first encountered the problem, I was new to PB and GTK and didn't understand what I was seeing. However, when I revisited the problem on Christmas Day, a few minutes testing revealed the problem and a simple solution.

All that's necessary is to put non-zero sizes on the gadgets. And if you do this with Guimauve's sample code it works just fine. I used gadget sizes of "800, 600" instead of "0, 0", but any positive values seem to work.

I'm surprised that the PB gurus didn't pick up on this. :wink:
For ten years Caesar ruled with an iron hand, then with a wooden foot, and finally with a piece of string.
~ Spike Milligan
Post Reply