Bug? Bug with edittext_textchanged event

chrisinky

Member
Licensed User
Longtime User
Hi,

I have a complex client/server app that I'm not sure I can share the entire code with but happy to do a zoom with someone to show them what is happening.

The server side sends a packet of data that contains everything to draw the GUI on the screen - this includes labels and edit text fields.

All of the edit texts are given a tag with their field name for me to keep track of.
This is a rough idea of how the program works:
1. Packet comes in from server
2. I remove all existing views
3. Process the packet and re-draw based on the new screen
4. I run a "clean up" sub that does some things (this is important is I iterate through the edittextfields on the screen here - when this happens - "FieldSecond" is present, but nothing else)
5. The LAST thing that happens is the textchanged event is being triggered, BUT it's for a edit text field that was on the "last" screen (based on the tag value).
6. User enters data - I send packet to server and when it responds the process starts over again


BUG? part:

So - app starts:
Screen is drawn with edittext lets call it "FieldFirst"
User enters text into that field - I store it in a map based on textchanged event
User hits enter - field sent to server, processed, server sends back a new packet
All views removed
New views drawn
FieldFirst is triggering a textchanged event AFTER a time where I itterate through all edittexts and it no longer exists....
This is a problem - because my code stores this value in a map - and when the user hits enter again I'm sending back to the server a value for a field that should not be on the screen.

My current workaround is:
In the edittext_textedchanged event code I iterate through all edittexts, if the tag of the sender matches the tag of a current field, I let it update the map, otherwise I skip

I can't understand why the event is triggering - bug?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Best if you can reproduce it in a small project.

The fact that you removed a view from the views tree doesn't mean that the view doesn't exist or that its events are disabled. I'm not sure what caused the event to be raised but it should be easy to filter it:
B4X:
Dim v As B4XView = Sender
If v.Parent.IsInitialized = False Then Return
 

LucaMs

Expert
Licensed User
Longtime User
To me this seems more like a question than a bug report in B4X or some library.

1741694039473.png
 

chrisinky

Member
Licensed User
Longtime User
I don't think that it is an actual bug, however it is a bug report so it can stay here.
Thanks for the help - I understand now that the event can fire even though the object no longer exists, I guess I didn't realize I needed to code around that - but understood now and will change my more complex iteration code to your more simple .isinitilazed.

thanks!
 
Top