Wish Check if a Layout exist

Filippo

Expert
Licensed User
Longtime User
Hi,

I would be good if during compilation the compiler checks if a layout exists.
In my case, a layout was not available in a b4xlib library and the app crashed when executing a function.

The wish also applies to B4a.

Many thanks in advance
Filippo
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1728030078713.png


It should show a warning
 

Sandman

Expert
Licensed User
Longtime User
Now that I'm thinking about it, I kind of think it makes sense the compiler would just stop if there's a layout missing. The only time for when it would be "acceptable" to not have a layout, is when it's in code that never runs, right?

Another thing, I've made the mistake to fail to include a layout in a b4xlib once, and while I'm not certain, I think I remember thinking that the "outer" project (that used the b4xlib) didn't have any warnings about the missing layout. Like I said, I could be wrong about this.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is possible that somewhere in your project there is a "dynamic loaded layout" and this cancels this warning. For example:
B4X:
Root.LoadLayout("MainPage" & i)

Now that I'm thinking about it, I kind of think it makes sense the compiler would just stop if there's a layout missing. The only time for when it would be "acceptable" to not have a layout, is when it's in code that never runs, right?
Warnings are important and developers should pay attention to them. I'm not sure that there is a case where this warning should be ignored but as seen in this case the compiler cannot always know whether a file is missing and it is better to go on the safe side and treat it as a warning.
 

Filippo

Expert
Licensed User
Longtime User
As you can see, the IDE does not show an error message.
I compiled the project again and started the app. When starting “mnuPrivacyPolicy_Click” the app crashes because the layout is not found.

1728203492819.png
 

LucaMs

Expert
Licensed User
Longtime User
I assume it's the fault of the Dialog you're using (which one? Which library? Better to use B4XDialog, since it's cross-platform).

I could create my own custom view that has a method called Lay (or George ?) to load a layout and the compiler wouldn't be able to control that. I mean the compiler wouldn't control the LoadLayout of that Dialog, just like it wouldn't control my Lay.
 
Last edited:

Filippo

Expert
Licensed User
Longtime User
I assume it's the fault of the Dialog you're using (which one? Which library? Better to use B4XDialog, since it's cross-platform).

I could create my own custom view that has a method called Lay (or George ?) to load a layout and the compiler wouldn't be able to control that. I mean the compiler wouldn't control the LoadLayout of that Dialog, just like it wouldn't control my Lay.
I have to say, to my regret, that you are right. :p

Better to use B4XDialog, since it's cross-platform)
My CustomDialog is also cross-platform(B4a and B4i). ;)
 
Top