xbmc/xbmc — pull request #4370 by jmarshallnz (2014-03-08 00:30:26+00:00)
Title: [python] ensure we lock the GUI prior to calling ClearItems. Fixes #14780

@jimfcarroll please check - should be sane enough.

(What was happening is that ClearFileItems() locks the CFileItemList lock, then iterates through and free's each item, which eventually calls into the texturemanager to release textures. Ofcourse, the texturemanager attempts to grab the graphics lock (why not, right? It's not as if we abuse it too much anyway...) to protect it's objects rather than having more fine-grained locks. Meanwhile, the UI is rendering which holds graphics lock and needs to query the CFileItemList (thus attempts to grab that lock) -> deadlock.

Ideally the usage of g_graphicsContext as a mutex needs to be severely trimmed, but in the meantime, ensuring that python grabs it first will do the trick here.