Method is too long !

Hi,

I have an application with a main window named “Window1” which contains a lot of objetcs (textfields, buttons, etc…).
Today when I try to add an object (button or canvas, etc. …) and when compiling, the compiler shows me the error message:

What is the problem ? Is there a limit of objects ?

Thank you for your help.

How many objects are we talking about?

Hundreds…

[quote=131321:@Stephane REVILLARD]Hi,

I have an application with a main window named “Window1” which contains a lot of objetcs (textfields, buttons, etc…).
Today when I try to add an object (button or canvas, etc. …) and when compiling, the compiler shows me the error message:
What is the problem ? Is there a limit of objects ?
[/quote]

The message refers to a method being too long. Not to too many controls. I tried to reproduce the issue with about 300 controls by duplicate and copy paste, it compiles and runs fine.

Do you have a method with a lot of code ? That would be it.

[quote=131327:@Michel Bujardet]The message refers to a method being too long. Not to too many controls. I tried to reproduce the issue with about 300 controls by duplicate and copy paste, it compiles and runs fine.

Do you have a method with a lot of code ? That would be it.[/quote]

As it is, my project works fine when I compile.

But now, when I want to add a new empty pushbutton (for example) the compiler displays the error :
This method is too long : Window1

The IDE writes a method for you that initializes the window. That virtual method is limited by the stack frame size just like any other method. Each control represents at least one local variable in the stack frame, possibly more. So, yes, there is a limit to the number of controls and other objects you can put on a window. Is there any way to partition all those controls into multiple windows? Or if you’re using a pagepanel or tabpanel, put each panel’s controls into a container. But with that many controls, I would worry about performance, not to mention functionality overload. You may want to refactor your interface.

I’d love to see this window because I know how the IDE writes the code and its been factored in a way to try & specifically avoid this issue. That was done some 6 or 7 years ago.

I’ve never encountered that error since and I have sample projects that have 1500+ controls on a window

A quick text search in the source code of compiler should reveal all the conditions that lead to the reported message.

Already know where the message comes from
I’m looking for a sample that induces it now because this condition should not be possible to encounter so I’m very curious about the sample where it does

[quote=131329:@Stephane REVILLARD]As it is, my project works fine when I compile.

But now, when I want to add a new empty pushbutton (for example) the compiler displays the error :
This method is too long : Window1[/quote]

Proof is in the pudding. Since this is reproductible, why don’t you file a private bug report that only you and Xojo team will see, with your project attached, and instructions to trigger the error ? That is probably the best way you will get a helpful answer.

Since there is no way to reproduce what you describe, I do not see how any of us could assist. Well, maybe an idea : instead of cramming so many controls onto the window, why not break them into Container Control modules ? I suspect 20 controls on a Container Control may generate much less code on a window than the said items attached directly to it.

Trying does not cost anything, anyway.

Are you using really long names for the controls?

Also, a neat trick is to combine your labels into control sets. Perhaps that will help.

Hi !

Thank you all for your help !

I think I’ll try to move some controls into a ContainerControl, but I don’t know how to do this.

As a test, I created a ContainerControl named ‘ContainerControl1’ and added a Pushbutton into it. Now I want to include it in the page 7 of the ‘PagePanel1’ in the ‘Window1’. How can I do it via the IDE ?

Thanks. :slight_smile:

[quote=131564:@Stephane REVILLARD]I think I’ll try to move some controls into a ContainerControl, but I don’t know how to do this.

As a test, I created a ContainerControl named ‘ContainerControl1’ and added a Pushbutton into it. Now I want to include it in the page 7 of the ‘PagePanel1’ in the ‘Window1’. How can I do it via the IDE ?
[/quote]

Drag the Container Control you have created over the page, and that will create an instance on it.

Thank you very much for the advice, now I’ll do some tests !

[quote=131564:@Stephane REVILLARD]Hi !

Thank you all for your help !

I think I’ll try to move some controls into a ContainerControl, but I don’t know how to do this.

As a test, I created a ContainerControl named ‘ContainerControl1’ and added a Pushbutton into it. Now I want to include it in the page 7 of the ‘PagePanel1’ in the ‘Window1’. How can I do it via the IDE ?

Thanks. :)[/quote]
I REALLY do want you to submit your app privately so I can wee whats causing this
That would be very helpful to me and long term to anyone else in the community that may experience this

Please

Please see what is the size of file “.xojo_window” of this Window1 and also how many lines are in this file.

A Desktop project in Xojo2014r2.1 on Windows 7 having 2000 TextField(s) on Window1, does not show this error and compiles without any problem. The IDE cannot seem to handle 2500 TextField(s) and becomes “Not responding”, most likely due to only 4GB RAM size.

Have not tried to add dummy executable code, in large quantity, in Window1. May try that next.

Just did and at line 40958 the compiler reported “This method is too long”. It also showed the code of that line and the method name.

OK, but where can I find this file ? I’ve not managed to find it.

[quote=131580:@Norman Palardy]I REALLY do want you to submit your app privately so I can wee whats causing this
That would be very helpful to me and long term to anyone else in the community that may experience this

Please[/quote]

I made this application for my company, it contains sensitive data. But I can try to send it to you if it remains safe.

Guess there are three file formats for Xojo project/source code. Binary, XML and text. Not sure which type of Xojo license allows text format files for Xojo projects. The “”.xojo_window" should be in the project folder if the project is using text format of the source code/project files.

Text is the one that separates everything. It is prudent to create a separate folder to save into it with that format, it creates several files.