Bug? Designer and B4A IDE Crash when I click on Designer Scripts

BvdB

Member
Licensed User
Longtime User
Summary
I have an Activity (screen layout), with Designer scripts to resize and scale for all the screen sizes.
In the app that I develop, it gives me an compile error, stating that there is an error in the designer script.
When I open adminpage.bal in the designer, it displays the basic layout as expected.
When I click on the Designer Script tab, the Designer and the IDE crash and close.

Reproduction
To make it easier to find en fix the error, I created a new B4A app called ActivityError.b4a
The problematic adminpage.bal is included and the images that are used in the layout.

If the ActivityError App is compiled it gives the following Error:

Here are the steps to reproduce the error:
  1. Open ActivityError.b4a in the editor (v2.7 or 3.0) both have the same symptom.
  2. Once in the IDE, Click on Designer menu.
  3. In the Designer UI, open adminpage.bal that resides in the Files folder.

  1. Click on the Designer Scripts tab and the Designer and IDE crash:

Click on Debug or Close Program and B4A closes.

Is there a way to extract the script code and then open the layout in the designer or is the only alternative to rebuild it from scratch?

Any help to get the activity restored will be appreciated.
An explanation/reason why it happened will help me to prevent recurrences in future.
Thanks in advance
 

Attachments

  • FixError.zip
    46.4 KB · Views: 220

Erel

B4X founder
Staff member
Licensed User
Longtime User
Here is your code:
B4X:
'All variants script
'AutoScaleAll 'uncomment to scale all views based on the device physical size.
If 100%x < 100%y Then
   Orientation = "P"
Else If 3 = 3
   Orientation = "L"
End If

ButtonFactor = ActivitySize * 20dip

pnlHolder.SetLeftAndRight (5dip, 100%x - 5dip)
pnlHolder.SetTopAndBottom (5dip, 100%y - 5dip)
imgLogo.Top = pnlHolder.Top
imgLogo.Left = pnlHolder.Left
pnlToolbar.Top = pnlHolder.Top
pnlToolbar.SetLeftAndRight (imgLogo.Right + 2.5dip, pnlHolder.Right-10dip)
btnBack.Top = pnlToolbar.Top - 5dip
btnBack.Left = pnlToolbar.Width - btnBack.Width
lblTitle.Height = pnlToolbar.Height
lblTitle.VerticalCenter = pnlToolbar.VerticalCenter
lblTitle.SetLeftAndRight (0, btnBack.Left)
btnLocationTypes.Height = ButtonFactor
btnLocationTypes.Width = ButtonFactor
btnLocations.Height = ButtonFactor
btnLocations.Width = ButtonFactor
btnCountries.Height = ButtonFactor
btnCountries.Width = ButtonFactor
btnSourceTypes.Height = ButtonFactor
btnSourceTypes.Width = ButtonFactor
btnSources.Height = ButtonFactor
btnSources.Width = ButtonFactor
btnLanguages.Height = ButtonFactor
btnLanguages.Width = ButtonFactor
btnImages.Height = ButtonFactor
btnImages.Width = ButtonFactor
btnTreeFamilies.Height = ButtonFactor
btnTreeFamilies.Width = ButtonFactor
btnPOITypes.Height = ButtonFactor
btnPOITypes.Width = ButtonFactor
btnPOI.Height = ButtonFactor
btnPOI.Width = ButtonFactor
btnTrees.Height = ButtonFactor
btnTrees.Width = ButtonFactor

If 100%x < 100%y Then 'Portrait Orientation
   TopRow = pnlToolbar.Bottom + 10dip
   BottomRow = pnlHolder.Bottom - 20dip
   LeftColumn = pnlHolder.Left
   RightColumn = pnlHolder.Right - 5dip
   Rows = 5
   Columns = 3
   RowSpacing = ((BottomRow - TopRow) - (ButtonFactor * Rows))/ Rows
   ColumnSpacing = ((RightColumn - LeftColumn) - (ButtonFactor * Columns)) / Columns
   'Row1
   btnLocationTypes.Top = TopRow
   btnLocationTypes.Left = LeftColumn
   btnLocations.Top = TopRow
   btnLocations.HorizontalCenter = pnlHolder.HorizontalCenter
   btnCountries.Top = TopRow
   btnCountries.Left = RightColumn - ButtonFactor
   'Row2
   btnSourceTypes.Top = TopRow + ButtonFactor + RowSpacing
   btnSourceTypes.Left = LeftColumn
   btnSources.Top = TopRow + ButtonFactor + RowSpacing
   btnSources.HorizontalCenter = pnlHolder.HorizontalCenter
   btnLanguages.Top = TopRow + ButtonFactor + RowSpacing
   btnLanguages.Left = RightColumn - ButtonFactor
   'Row3
   btnImages.Top = TopRow + (ButtonFactor * 2) + (RowSpacing * 2)
   btnImages.Left = LeftColumn
   btnTreeFamilies.Top = TopRow + (ButtonFactor * 2) + (RowSpacing * 2)
   btnTreeFamilies.HorizontalCenter = pnlHolder.HorizontalCenter
   btnTrees.Top = TopRow + (ButtonFactor * 2) + (RowSpacing * 2)
   btnTrees.Left = RightColumn - ButtonFactor   
   'Row4
   btnPOITypes.Top = TopRow + (ButtonFactor * 3) + (RowSpacing * 3)
   btnPOITypes.Left = LeftColumn
   btnPOI.Top = TopRow + (ButtonFactor * 3) + (RowSpacing * 3)
   btnPOI.HorizontalCenter = pnlHolder.HorizontalCenter
   'Row5
Else   'Landscape Orientation
   TopRow = lblTitle.Bottom + 5dip
   BottomRow = pnlHolder.Bottom - 10dip
   LeftColumn = pnlHolder.Left
   RightColumn = pnlHolder.Right - 5dip
   Rows = 3
   Columns = 5
   RowSpacing = ((BottomRow - TopRow) - (ButtonFactor * Rows))/ Rows
   ColumnSpacing = ((RightColumn - LeftColumn) - (ButtonFactor * Columns)) / Columns + 7.5dip
   'Row1
   btnLocationTypes.Top = TopRow
   btnLocationTypes.Left = LeftColumn
   btnLocations.Top = TopRow
   btnLocations.Left = LeftColumn + ButtonFactor + ColumnSpacing
   btnSourceTypes.Top = TopRow
   btnSourceTypes.HorizontalCenter = pnlHolder.HorizontalCenter
   btnSources.Top = TopRow
   btnSources.Left = LeftColumn + (ButtonFactor*3) + (ColumnSpacing*3)
   btnCountries.Top = TopRow
   btnCountries.Right = RightColumn
   'Row2
   btnImages.Top = ((BottomRow - TopRow)/2) - (ButtonFactor /2) + TopRow
   btnImages.Left = LeftColumn
   btnTreeFamilies.Top = ((BottomRow - TopRow)/2) - (ButtonFactor /2) + TopRow
   btnTreeFamilies.Left = LeftColumn + ButtonFactor + ColumnSpacing
   btnTrees.Top = ((BottomRow - TopRow)/2) - (ButtonFactor /2) + TopRow
   btnTrees.Left = LeftColumn + (ButtonFactor*2) + (ColumnSpacing*2)
   'btnLanguages.Top = ((BottomRow - TopRow)/2) - (ButtonFactor /2) + TopRow
   'btnLanguages.Left = LeftColumn + (ButtonFactor*3) + (ColumnSpacing*3)
   btnLanguages.Top = ((BottomRow - TopRow)/2) - (ButtonFactor /2) + TopRow
   btnLanguages.Right = pnlHolder.Right - 5dip
   'Row3
   btnPOI.Bottom = BottomRow
   btnPOI.Left = LeftColumn
   btnPOITypes.Bottom = BottomRow
   btnPOITypes.Left = LeftColumn + ButtonFactor + ColumnSpacing
   'btnCountries.Top = TopRow
   'btnCountries.Left = LeftColumn + (ButtonFactor*2) + (ColumnSpacing*2)
   'btnSourceTypes.Top = TopRow
   'btnSourceTypes.Left = LeftColumn + (ButtonFactor*3) + (ColumnSpacing*3)
   'btnSources.Top = TopRow
   'btnSources.Left = LeftColumn + (ButtonFactor*4) + (ColumnSpacing*4)
End If

The problem was that you wrote:

If If 100%x < 100%y Then

The second 'if' killed the designer script parser. It is fixed for v3.0.
 

BvdB

Member
Licensed User
Longtime User
Thanks Erel, much appreciated!
Should I steer away from If's in designer or what can I do if this occur again?
I don't want to bother you guys with such issues.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…