PDA

View Full Version : Do Windows Actually Close?



UrsaTeddy
December 29th, 2021, 09:53
Greetings,

I have been playing around with opening/closing windows based on their type and I have come across a behaviour that would lead me to think that windows are not really closed.

I have an extension that simply closes windows based on their type (or all of them). Based on a boolean parameter they are either reopened or not.

So I opened 6 windows.

50617

I then proceed to close all of those windows except for one. This is performed with the X on each window.

50618

I then run my extension that will close all windows that are allowed to be close (so no chat, no menus, no desktop items).

50619

I now reopen the story window and run the extension to close and then reopen all allowed windows.

50620

You will see in the image that all the other windows that were opened previously (except the Assets window) are reopened.

My code ...


function Refresh_Windows_By_Type(of_types, reopen_windows)
if reopen_windows == nil then reopen_windows = true end

local window_list = Interface.getWindows(true) <--- NOTE I AM ASKING ONLY FOR VISIBLE WINDOWS
for k,v in pairs(window_list)
do
local window_type = v.getClass()

if not TABLE.Is_In_Table(WM_EXCLUDE, window_type) <--- ensures the window is allowed to be closed
then
if TABLE.Is_Empty_Table(of_types) or TABLE.Is_In_Table(of_types, window_type)
then
local db_node = v.getDatabaseNode() or ""
local v_wx, v_wy = v.getPosition()
v.close()
if reopen_windows
then
window = Interface.openWindow(window_type, db_node)
window.setPosition(v_wx, v_wy)
end
end
end
end
end


So either the windows are not truly being closed and only hidden from view - hence the issue with getWindows(true) - or I am missing something here.

All help would be appreciated.
D

jharp
December 29th, 2021, 15:57
I can confirm that Interface.getWindows() seems to return windows that are no longer in existance. The MaInspector uses that interface and it now shows items that no longer exist.
Edit: I thought this a new bug but it seems this is a fix to speed up index windows (class: masterindex). It does not happen with id-* windows. I believe Moon was making larger indexes faster and less jumpy so this likely has something to do with that work. I suggest you add it to your ignore list or work around it somehow.

Jason

UrsaTeddy
December 30th, 2021, 04:21
Unfortunately I need the ability to open/close masterindex windows ... I have created two further sets of code that can target a node based window and a window by title ... so for now this should get me over this issue.

Thanks for the confirmation - I thought I was going insane with what was happening.

D

Moon Wizard
December 30th, 2021, 20:19
The masterindex windows are specifically not designed to be closed, but to be hidden instead. The reason is because they are very resource-intensive to build when first opened.

Regards,
JPG

UrsaTeddy
December 31st, 2021, 12:39
Okay that is more information ... as I stated I wrote extra code to allow me to target windows even more specifically instead of just targeting "all windows".

D