D15025: Avoid crash with on scripted window teardown with threaded quick render loop

David Edmundson <[email protected]>
Newsgroups gmane.comp.kde.devel.kwin
Message-ID <[email protected]>
davidedmundson created this revision.
davidedmundson added a reviewer: KWin.
Herald added a project: KWin.
Herald added a subscriber: kwin.
davidedmundson requested review of this revision.

REVISION SUMMARY
  Qt render loops behave quite differently to each other.
  
  KWin scripting as a workaround for another situation cleans
  (17553e5a1fb72a92dbbff3fa6bc7d55b8f1a0123 <https://phabricator.kde.org/R108:17553e5a1fb72a92dbbff3fa6bc7d55b8f1a0123>) handles tracking of script
  windows by deleting the underlying window handle on hide.
  
  This currently happens before the window gets the hideEvent.
  
  Arguably this is a quirk with Qt, but in the current state:
  
  - QSGThreadedRenderLoop deletes the platform window and cleans up
  - We then get the hide() event. This no-ops because there's no window. (else branch of     case WM_TryRelease in qsgthreadedrenderloop.cpp)
  - We carry on rendering animations despite having no platform
  - undefined behaviour
  
  Normally this isn't a problem as typically destruction of the platform window
  happens only when a window is being deleted, we're messing with Qt
  internals here.
  
  If we make sure the QHideEvent is processed by the render loop first,
  things seem fine.
  
  BUG: 397767

TEST PLAN
  Ran QSG_RENDER_LOOP=threaded
  Read output with scenegraph logging rules on

REPOSITORY
  R108 KWin

BRANCH
  master

REVISION DETAIL
  https://phabricator.kde.org/D15025

AFFECTED FILES
  scripting/scripting.cpp

To: davidedmundson, #kwin
Cc: kwin, mkulinski, ragreen, jackyalcine, Pitel, iodelay, bwowk, ZrenBot, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, sebas, apol, mart
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.