View previous topic :: View next topic |
Author |
Message |
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Mon Oct 03, 2022 7:41 am Post subject: MemoryRecord.beginUpdate |
|
|
Hi all,
The MemoryRecord class does not appear to have a beginUpdate method.
I wonder how to add 100s of MemoryRecords (having a few child memrecs) and prevent UI updates while the LUA script is running (to prevent updating the address list while working on it).
Any ideas/workarounds?
Thank you!
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Mon Oct 03, 2022 12:07 pm Post subject: |
|
|
You could try calling beginUpdate on the backing treeview, but I'm not sure how reentrency comes into play if CE calls that as well.
Maybe instead of creating and destroying memrecs all the time, you could create them once and hide / show them as needed.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Tue Oct 04, 2022 3:51 am Post subject: |
|
|
Thank you for the response!
How would I find the underlying treeview object (of the memoryrecord)?
The second it a good idea, but the list is dynamic - could be 100, 200, 500,1000 entries. I want to build it to exactly as long as it needs to be.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Tue Oct 04, 2022 10:37 am Post subject: |
|
|
Code: | local control
for i = 0, AddressList.ControlCount - 1 do
local c = AddressList.Control[i]
if c.ClassName == 'TTreeviewWithScroll' then
control = c
break
end
end
assert(control, 'AddressList treeview not found') |
Another alternative would be to have a script in the address list simply show / hide a form that you control as you see fit. This would be more complicated to code but might look better.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Oct 04, 2022 11:40 am Post subject: |
|
|
AddressList.List might work as well
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Tue Oct 04, 2022 12:27 pm Post subject: |
|
|
I copy-pasted your code and added the begin and endUpdate calls:
Code: | local control
for i = 0, AddressList.ControlCount - 1 do
local c = AddressList.Control[i]
if c.ClassName == 'TTreeviewWithScroll' then
control = c
break
end
end
--assert(control, 'AddressList treeview not found'); not needed, we can still run.
if control and control~=nil then
control.beginUpdate()
end
...
if control and control~=nil then
control.endUpdate()
end |
Well, wow, just wow.
The list was usually built in 5-7 seconds.
With this change, it's done in half a sec!
Thank you, much appreciated!
Note to self: code yields access violation when executed asych
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Tue Oct 04, 2022 1:38 pm Post subject: |
|
|
Dark Byte wrote: | AddressList.List might work as well | I thought I checked that before, but it seems I forgot. This works for me.
Csimbi wrote: | Note to self: code yields access violation when executed asych | Any access to the GUI must be done through the main thread.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Tue Oct 04, 2022 1:41 pm Post subject: |
|
|
you can use
Code: |
local somelocalthreadvars
synchronize(function()
--gui code that can access somelocalthreadvars and other upvalues
end)
|
Just keep in mind that the code inside synchronize runs inside the main thread, so do not enter infinite/long loops
Best way of using this is build a list of data, and then synchronize it.
Perhaps not all at once, but in small blocks so the GUI keeps responsive
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Wed Oct 05, 2022 1:12 am Post subject: |
|
|
Thank you, both!
I'll toy with these ideas.
DB,
I am not sure what you mean by using AddressList.List - the AddressList control does not seem to have a beginUpdate method.
Do you mean that AddressList.List is actually the TreeView object?
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Wed Oct 05, 2022 10:27 am Post subject: |
|
|
`AddressList.List` is the treeview the address list uses to display information. It basically replaces the few lines of code I wrote to find the treeview. i.e.:
Code: | AddressList.List.beginUpdate()
...
AddressList.List.endUpdate() |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
Csimbi I post too much Reputation: 92
Joined: 14 Jul 2007 Posts: 3102
|
Posted: Wed Oct 05, 2022 10:42 am Post subject: |
|
|
Neat, thanks!
|
|
Back to top |
|
|
|