CloseGadgetList() bug ???

Linux specific forum
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

CloseGadgetList() bug ???

Post by Joris »

Hi,

(Problem exist on Ubuntu, not under windows.)
I think I have isolated the problem, in the code below, of not being able to draw the gadgets.
OpenGadgetList(hnd) and CloseGadgetList() combined with the flag #PB_Canvas_Container.
Yet why is still not clear to me.

If the #PB_Canvas_Container is not set only CloseGadgetList() gives problems, OpenGadgetList(hnd) doesn't.
If the #PB_Canvas_Container is set OpenGadgetList(hnd) and CloseGadgetList() gives problems. No gadgets are drawn.
So the sollution looks more like, add gadgets at runtime : change the flag #PB_Canvas_Container.
What else if adding gadgets at runtime to more then one canvas ?

To me there is something wrong in the order of using these three, (or else just in CloseGadgetList().
Can anyone clarify this

Thanks

Code: Select all

;******************************************************** 
;{******************************************************** 
Structure Gadget_Set
  x.w                                                                                             
  y.w                                                                                             
  w.w                                                                                             
  h.w   
  fcolor.a    ;kleur nr fill dot-kader
  bcolor.a    ;kleur nr achtergrond  
  mark.a      ;runtime markering voor delete oid.
  prnt.u      ;list index van het parent Gadget gebruik nog verder invoeren (zie ook uitleg bovenaan)
  type.u      ;Gadget type constante
  atrb.l      ;Gadget flag specifikaties binair ingevoegd MAAR op volgorde van de tekst-lijst met Flags
  flag.i      ;som van alle Flag-specifikaties decimale vorm     INTEGERS ACHTERAAN PLAATSEN
  idx.i
EndStructure
Structure Save_Ob
 name.i      ;som van alle specifikaties decimale vorm     INTEGERS ACHTERAAN PLAATSEN
 spec.i
 typ.u
EndStructure
Structure wXYWH  ;OPGELET NIEUW FORMAAT ALLES ALS WORD I.P.V. LONG
  x.w            ;door 2-bytes Word ipv Unicode gebruik kunnen ook negatieve waarde gebruikt worden
  y.w            ;nuttig bij rubberdrawbox met "negatieve muisbewegingen" !
  w.w
  h.w
EndStructure
;******************************************************* 
Global NewList Ob.Gadget_Set() 
Global NewList xy.wXYWH() 
Global result.s, text.s, pad.s, userpad.s, S_flag.s, Ob_Edit.Gadget_Set, SOb.Save_Ob, btn_info 
Global.i Window_0,Canvas_0, btn1, a, b,x,y,w,h,btn1, btn2
;}********************************************************
;********************************************************
Procedure  AddGadgetSample(spec.i)
      
      If spec    
             Debug "tweede"
          AddElement(Ob()) : Ob()\x= 95 : Ob()\y= 80 : Ob()\w=90 : Ob()\h=40 :  Ob()\type = #PB_GadgetType_Button                
          AddElement(Ob()) : Ob()\x=207 : Ob()\y= 80 : Ob()\w=90 : Ob()\h=40 :  Ob()\type = #PB_GadgetType_Button                
          AddElement(Ob()) : Ob()\x= 95 : Ob()\y=132 : Ob()\w=90 : Ob()\h=40 :  Ob()\type = #PB_GadgetType_Button                 
          AddElement(Ob()) : Ob()\x=207 : Ob()\y=132 : Ob()\w=90 : Ob()\h=40 :  Ob()\type = #PB_GadgetType_Button                 
          
          AddElement(Ob()) : Ob()\x=335 : Ob()\y=210 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_CheckBox                 
          AddElement(Ob()) : Ob()\x=397 : Ob()\y=210 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_CheckBox                 
          AddElement(Ob()) : Ob()\x=335 : Ob()\y=245 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_CheckBox                 
          AddElement(Ob()) : Ob()\x=397 : Ob()\y=245 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_CheckBox           
          
          AddElement(Ob()) : Ob()\x=335 : Ob()\y=280 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_Option                 
          AddElement(Ob()) : Ob()\x=397 : Ob()\y=280 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_Option                  
          AddElement(Ob()) : Ob()\x=335 : Ob()\y=315 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_Option                  
          AddElement(Ob()) : Ob()\x=397 : Ob()\y=315 : Ob()\w=55 : Ob()\h=30 :  Ob()\type =#PB_GadgetType_Option                  
      Else
          Debug "eerste"
          AddElement(xy()) : xy()\x= 95+200 : xy()\y= 80 : xy()\w=90 : xy()\h=40 
          AddElement(xy()) : xy()\x=207+200 : xy()\y= 80 : xy()\w=90 : xy()\h=40 
          AddElement(xy()) : xy()\x= 95+200 : xy()\y=132 : xy()\w=90 : xy()\h=40 
          AddElement(xy()) : xy()\x=207+200 : xy()\y=132 : xy()\w=90 : xy()\h=40 
          
          AddElement(xy()) : xy()\x=535 : xy()\y=210 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=597 : xy()\y=210 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=535 : xy()\y=245 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=597 : xy()\y=245 : xy()\w=55 : xy()\h=30 
          
          AddElement(xy()) : xy()\x=535 : xy()\y=280 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=597 : xy()\y=280 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=535 : xy()\y=315 : xy()\w=55 : xy()\h=30 
          AddElement(xy()) : xy()\x=597 : xy()\y=315 : xy()\w=55 : xy()\h=30 
      EndIf
      
EndProcedure    
;********************************************************
Procedure Drop_Gadget_Selected(*ob.Gadget_Set, idx.i)
  Protected.i a, val1, val2, val3, last_idx, txt.s 
  
  With *ob 
  
     txt="gdt" 
    Debug Str(\type)+ " drop  "+ RSet(Str(\x),3," ") + ","+  RSet(Str(\y),3," ") + ","+  RSet(Str(\w),3," ") + ","+  RSet(Str(\h),3," ") + " "+ txt + "  flg= " +Str(\flag)
      
    Select \type
      Case #PB_GadgetType_Button        : \idx = ButtonGadget(#PB_Any, \x,\y,\w,\h, txt, \flag)	      ;1 
      Case #PB_GadgetType_ButtonImage   : \idx = ButtonImageGadget(#PB_Any, \x,\y,\w,\h, val1, \flag) ;19
      Case #PB_GadgetType_Calendar      : \idx = CalendarGadget(#PB_Any, \x,\y,\w,\h, val1, \flag)    ;20
      Case #PB_GadgetType_Canvas        :; \idx = CanvasGadget(#PB_Any, \x,\y,\w,\h, \flag)           ;33
      Case #PB_GadgetType_CheckBox      : \idx = CheckBoxGadget(#PB_Any, \x,\y,\w,\h, txt, \flag)     ;4 
      Case #PB_GadgetType_ComboBox      : \idx = ComboBoxGadget(#PB_Any, \x,\y,\w,\h, \flag)          ;8 
      ;OPGELET CONTANER GADGETS WORDEN MET HANDLE OPGEZOCHT EN DUS INVOER MET GADGETID => SetGadgetData(\idx, GadgetID(\idx))
      Case #PB_GadgetType_Container     : \idx =ContainerGadget(#PB_Any, \x,\y,\w,\h, \flag)
      Case #PB_GadgetType_Frame         : \idx = FrameGadget(#PB_Any, \x,\y,\w,\h, txt, \flag)        ;7 
      Case #PB_GadgetType_Option        : \idx = OptionGadget(#PB_Any, \x,\y,\w,\h, txt)              ;5 
      EndSelect 
    last_idx=\idx
  EndWith
  
EndProcedure
Procedure  Add_Element(type.u, flag.i, atrb.l, prnt.u)
  
  AddElement(Ob())
  Ob()\type =#PB_GadgetType_Button ; type
  Ob()\flag = flag      
  Ob()\atrb = atrb      
  Ob()\prnt = prnt
    
EndProcedure
Procedure  Position_Added_Gadgets(hnd.i)           ;PLAATSEN VAN AT RUNTIME GETEKENDE GADGETS 
  Protected grid.i 
  Static parent_id.u
  
  OpenGadgetList(hnd)                    ;***************problem*****************
  
  With Ob_Edit
    
    ForEach xy()
      Add_Element(\type, \flag, \atrb, parent_id)  
      CopyMemory(@xy(), @Ob(), SizeOf(wXYWH))
      Drop_Gadget_Selected(Ob(), ListIndex(Ob()))  
    Next
    
  EndWith 
  
  CloseGadgetList()                         ;***************problem*****************
  
EndProcedure
Procedure Remove_All_Gadgets()
   ClearList(xy())
   ClearList(Ob())
  
EndProcedure
Procedure Window_0_Events(event)   ; GADGET PLAATSING WINDOW
  Protected.i x,y,tekst.s 
 
  Select event
     ;********************************************************  
    Case #PB_Event_CloseWindow :    End
    Case #PB_Event_SizeWindow :     ResizeGadget(Canvas_0,#PB_Ignore, #PB_Ignore, WindowWidth(Window_0), WindowHeight(Window_0)) 
    Case #PB_Event_Gadget
      ;******************************************************** 
      Select EventGadget()
        Case btn1 : 
          Remove_All_Gadgets()
          AddGadgetSample(0)
          Position_Added_Gadgets(Canvas_0)
          
        Case btn2 : 
          ;deze worden wel geplaatst  
          Remove_All_Gadgets()
          AddGadgetSample(1)
          ForEach Ob()
            Drop_Gadget_Selected(Ob(), ListIndex(Ob()))  
          Next
          
         Case Canvas_0 : 
          Select EventType()
            Case #PB_EventType_KeyDown 
            Case #PB_EventType_LeftButtonDown 
            Case #PB_EventType_MouseMove  :
           Case #PB_EventType_RightButtonDown 
                     
          EndSelect
          ;******************************************************** 
      EndSelect  
      
  EndSelect   
    
EndProcedure
;********************************************************
Procedure OpenWindow_0(x = 0, y = 0, width = 800, height = 700)
 Window_0 = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, width, height, "Testing", #PB_Window_SystemMenu |#PB_Window_ScreenCentered |#PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
  Canvas_0 = CanvasGadget(#PB_Any,0, 0, width, height, #PB_Canvas_Keyboard) ;| #PB_Canvas_Container) ; | #PB_Canvas_ClipMouse)
  btn1 = ButtonGadget(#PB_Any, 700,20,50,20, "Set 1")	      
  btn2 = ButtonGadget(#PB_Any, 700,60,50,20, "Set 2")	      
EndProcedure
Procedure Eventloop()
      
      Repeat 
        EventID = WaitWindowEvent() 
        If EventID 
            Select EventWindow() 
              Case Window_0
                Window_0_Events(EventID) 
            EndSelect 
        EndIf 
      ForEver 
  
EndProcedure
OpenWindow_0()
Eventloop()
;errors bij reuniform outpu aanmaak van nieuwe gadgets :
; [10:17:02] [WARNING] GLib-GIO (Debug): _g_io_module_get_default: Found Default implementation gvfs (GDaemonVfs) For ‘gio-vfs’
; [10:17:26] [WARNING] Gtk (CRITICAL): gtk_layout_put: assertion 'GTK_IS_LAYOUT (layout)' failed
; [10:17:26] [WARNING] Gtk (CRITICAL): gtk_widget_realize: assertion 'widget->priv->anchored || GTK_IS_INVISIBLE (widget)' failed
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
mestnyi
Addict
Addict
Posts: 995
Joined: Mon Nov 25, 2013 6:41 am

Re: CloseGadgetList() bug ???

Post by mestnyi »

look what happens without the flag.

Code: Select all

If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(10, 10, 10, 200, 200);, #PB_Canvas_Container)
  
  OpenGadgetList(10)
  CloseGadgetList( )
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: CloseGadgetList() bug ???

Post by Joris »

Please read clearly what I wrote.

And, did you test it under ubuntu (linux) ?
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CloseGadgetList() bug ???

Post by mk-soft »

Its a bug, make a linux bug-report ...

Code: Select all


Procedure Main()
  Protected dx, dy
  
  If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    dx = WindowWidth(0)
    dy = WindowHeight(0)
    
    CanvasGadget(10, 10, 10, dx - 20, dy - 50, #PB_Canvas_Container)
    CloseGadgetList()
    
    ButtonGadget(0, 10, dy - 35, 100, 30, "Add")
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Break
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              OpenGadgetList(10)
              ButtonGadget(1, 20, 20, 100, 30, "Remove")
              CloseGadgetList()
            Case 1
              FreeGadget(1)
              
          EndSelect
      EndSelect
    ForEver
    
  EndIf
EndProcedure : Main()
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
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: CloseGadgetList() bug ???

Post by Joris »

Isn't this good enough ? I thought it is...
https://www.purebasic.fr/english/viewto ... 05#p582405
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: CloseGadgetList() bug ???

Post by mk-soft »

Please always but reports with running code !

And

Change Titel:
CanvasGadget OpenGadgetList

That is the problem ...
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
Post Reply