Var c As Control = w.Control(iter) - or every single test Desktop project fails under Linux

Just downloaded Xojo for Linux, opened first Desktop test project and it immediately failed to build and run. Tried another. Failed. Tried another failed. Seriously? You want me to use Xojo as a platform for developing applications for Linux and can’t even provide a single test project that works under a common distribution (Pop OS / Ubuntu) and Gnome?

#If TargetLinux Then
  Declare Sub gtk_widget_get_preferred_size Lib "libgtk-3" _
  (widget As Integer, ByRef minSize As GtkRequisition, ByRef naturalSize As GtkRequisition)
  Var minSize, naturalSize As GtkRequisition
  
  For iter As Integer = 0 To w.ControlCount - 1
    Var c As Control = w.Control(iter)
    
    If c IsA RectControl Then
      gtk_widget_get_preferred_size(c.Handle, minSize, naturalSize)
      Var rc As RectControl = RectControl(c)
      rc.Height = minSize.Height
    End If
  Next
#Endif

Extensions.ResizeControlsForLinux, line 12
Type mismatch error. Expected class Control, but got Object
Var c As Control = w.Control(iter)

Yes - I am new to Xojo, I am a lousy developer (I would not even call myself one) - but is a single test project that works too much to ask for?

If anyone could help me fixing the crash to have a look at the examples - it would be much appreciated. Thanks.

I’m not here to apologise on behalf of Xojo but they have just put out a big release that affected a lot of systems including this demo and probably others. I’ve just installed linux in a vm to test this for you as I don’t usually use linux. Letting me know which example it was would have made my job a little easier as there are quite a few to check :wink: which is probably one of the other reasons why some little errors like this might slip through.

If you have any more questions, please do let us know.

Try this code instead:

#If TargetLinux Then
  Declare Sub gtk_widget_get_preferred_size Lib "libgtk-3" _
  (widget As Integer, ByRef minSize As GtkRequisition, ByRef naturalSize As GtkRequisition)
  Var minSize, naturalSize As GtkRequisition
  
  For iter As Integer = 0 To w.ControlCount - 1
    Var c As Object = w.Control(iter)
    
    If c IsA RectControl Then
      gtk_widget_get_preferred_size(Integer(Control(c).Handle), minSize, naturalSize)
      Var rc As RectControl = RectControl(c)
      rc.Height = minSize.Height
    End If
  Next
#Endif

PS. I think there should only be 4 projects where this specific issue occurs, which isn’t bad considering the number of examples included with Xojo, again, not making excuses :slight_smile:

Again, not a big linux guy but I believe that if you follow these steps, I think it will fix any issues you might see with control sizes being out of whack:

2 Likes

Julian, many thanks. Your code snippet prevents a crash. Unfortunately it does not prevent a screwed up interface …

Many thanks for this tip as well. It makes it a little better but it is still way off.

From what I gather browsing this forum - Linux is not a priority for Xojo and you have to tweak a lot to make it work and it can and will break every time GTK, Gnome, and Co change something?

Thanks again for your help.

Sorry I didn’t really pay attention to what the code was doing, I just made it run, the fundamentals of control base types recently changed, and the examples hadn’t followed, try this:

#If TargetLinux Then
  Declare Sub gtk_widget_get_preferred_size Lib "libgtk-3" _
  (widget As Integer, ByRef minSize As GtkRequisition, ByRef naturalSize As GtkRequisition)
  Var minSize, naturalSize As GtkRequisition
  
  For iter As Integer = 0 To w.ControlCount - 1
    Var c As Object = w.Control(iter)
    
    If c IsA DesktopUIControl Then
      gtk_widget_get_preferred_size(Integer(DesktopUIControl(c).Handle), minSize, naturalSize)
      Var rc As DesktopUIControl = DesktopUIControl(c)
      rc.Height = minSize.Height
      rc.Width = minSize.Width
    End If
  Next
#Endif

This is what I see with Normalize Control Sizes unchecked:

image

1 Like
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.