Fixes a crash reported by A.Prokoudine when opening a session with visible plugin GUIs
I would have loved to split this apart, but there are just so many interrelated changes, it makes little sense and would be a huge effort that would break future git bisect use because so many intermediate commits would not compile