Android Question button crash with code inside, no crash without code inside

DALB

Active Member
Licensed User
Hello everyone,

I've a famous and strange behaviour from a button.
With the following code

B4X:
Sub btnCalculsMoyJ_Click

    Dim nc As Int=Table1.SelectedRows
   Log(nc)
    ToastMessageShow("what Happens ?'","???")
   
End Sub
the app crashes without any reason and I have no line in the log.

with this code

B4X:
Sub btnCalculsMoyJ_Click
   
End Sub
I have no crash

1) I did a copy of a button and obtain the crash
2) I deleted it and recreated it as a new view
3) I closed the IDE and restarted it

In these three actions the crash remains if I write something in the area.
could it be a bug ?
 

DALB

Active Member
Licensed User
I'm in Debug mode...
 

DALB

Active Member
Licensed User
How deep is my stupidity...!!!

B4X:
lst=Table1.SelectedRows
    Log(lst.Size)
is the answer. I thought about it when you answered me !

But if no line is selected I'm obliged to put a try/Catch method otherwise the crash appears.

Thanks much mio amico d'Italia
 

klaus

Expert
Licensed User
But if no line is selected I'm obliged to put a try/Catch method otherwise the crash appears.
This sounds strange to me, because I tested this in the demo program and it works without an error.
In the case with no row selected, Log(lst.Size) returns 0 !?
I tried to reproduce your problem, but without success.
So, can you please post a small project showing the problem?
Which version of the Table class are you using, the latest version is 3.04?
 

DALB

Active Member
Licensed User
My last version of table Class is 3.04

I've modified my code and now it works with a call to a function like this:

B4X:
Sub btnCalculsMoyJ_Click
    faireLeCalculEntreDeuxLignes
End Sub
Even if I found a way, I don't like not understand what hapens, but here, i'm a little bit stuck up because of my delay.
I'll have a look in a moment.
Thanks for your attention
 

klaus

Expert
Licensed User
Can't you post a small project showing the problem or even the whole project.
The code snippet in post #7 doesn't give any information to understand what happens.
What was the original code in Sub btnCalculsMoyJ_Click ?
When it happens, do you click on the button before the Table is filled?
 

DALB

Active Member
Licensed User
I have only written what is in post #1, no more.

I only load a Table like this
B4X:
Table1.ClearAll
    Table1.LoadSQLiteDB(Starter.SQL1, "SELECT * FROM releve ORDER BY id DESC", True)
Just after this code, I put
B4X:
Sub btnCalculsMoyJ_Click

    Dim nc As Int=Table1.SelectedRows
   Log(nc)
    ToastMessageShow("what Happens ?'","???")
  
End Sub
for a button. There is nore more at this moment.
In the button code I begun to code some lines to make statistics.
It's the beginning of an activity I started.

The table is filled by a SQLite table in which there are numbers and strings.
The problem, in fact, is that there is no more things to show, that's why I was surprised having this crash.
Maybe a difficult issue !!!
 

aeric

Well-Known Member
Licensed User
How deep is my stupidity...!!!

B4X:
lst=Table1.SelectedRows
    Log(lst.Size)
is the answer. I thought about it when you answered me !

But if no line is selected I'm obliged to put a try/Catch method otherwise the crash appears.

Thanks much mio amico d'Italia
B4X:
Log(Table1.SelectedRows.Size)
 

DALB

Active Member
Licensed User
thank for answering.
Klaus, here is the zip.
In line 1524 you will see the button code. With the lines posted before, it crashes. With the call subroutine, all goes well (at this moment).

I would be curious to listen to you. It's a project, so , many subs wil be rearranged.
 

Attachments

klaus

Expert
Licensed User
Sorry, but I can't test your project, the bal file(s) are missing.
Didn't you zip the project from the IDE menu Export To Zip ?
To minimize the zip file size you can remove the Objects folder and the .b4a.meta file from the project before zipping it.
In which line in Sub faireLeCalculEntreDeuxLignes does the program crash?
Put a breakpoint at line 1535 lst=Table1.SelectedRows.
When the program stops at this line, continue the execution step by step and look what happens.
 
Last edited:

DALB

Active Member
Licensed User
Hooo !
I explain again.
When I used the code as presented in post #9, the app crashes.
But, I was obliged to change it not to crash. So, I used the code mentioned in post #7...And it works.
I only wanted to know why it crashed in one case and not in the second.

I've found a solution, but the fact the app crashes must have an origin. It's why I gave you my elements only to know if it can be explained. But the code in post #7 works well.

So, now with code #7 and breakpoint, it's good, I don't have any problem.

B4X:
Sub btnCalculsMoyJ_Click
    faireLeCalculEntreDeuxLignes
End Sub
Sorry not to be clear enough !
 

DALB

Active Member
Licensed User
No, I added it to see what happens, but only the 2 first lines made the code crashed.
I don't know if opening several softwares can produced in such a way a bug like this. My computer seems to be build for that but I don't know how Windows manage the memory for each one. Maybe some of them interact.
I add too that sometimes my computer runs during many days without being refreshed.
At the moment I write this, Publisher from microsoft starts alone but I never did anything for that.
 

DALB

Active Member
Licensed User
Thank you Klaus? Next time, if it happens again with more code in my project, I'll try to catch all the elements, because here, it's only the beginning of one.
 
Top