XQuartz internal-behind-the-scenes question
XQuartz internal-behind-the-scenes question
- Subject: XQuartz internal-behind-the-scenes question
- From: René J.V. Bertin <email@hidden>
- Date: Fri, 12 Sep 2014 14:45:17 +0200
Hello - Jeremy in particular
Not really a question for a *users* list, but here goes.
I'm facing a situation in a KDE application where a crash occurs because I'm deleting a Qt object corresponding to a UI element that may still have Cocoa events pending (or be currently handling an event somewhere higher up in the call stack). Qt provides a `deleteLater` method which is intended for cases where to-be-deleted object still has events pending and/or might be in use in a different thread; it defers the delete till after exit from the event loop (and/or until the owning thread exits?). Indeed, using that deferred delete systematically avoids the crash.
I'm rather sure that there must be ObjC code and objects somewhere deep in XQuartz's OS X specific code, and that there are situations where an X11 object corresponding to a UI element is being freed in similar conditions, for instance because the user clicks on a button that should close a dialog (rather than close the widget which ultimately leads to deleting the object).
The crash I mentioned occurs only on OS X, not on Linux, and the app's authors think I shouldn't follow advice found on forums (showing near-identical backtraces to the one I'm seeing) to prefer using the `deleteLater` method rather than a direct/immediate delete, at least on OS X. They're inclined to think there's a bug in Qt. Myself, I think we're in situation created by reimplementing a framework/API (ultimately designed for X11, I think) on top of OS X APIs. I know from personal experience in this domain that it's not at all difficult to delete objets before all its events have been handled completely on OS X. In my experience, the bug would be to do an immediate delete rather than a deferred delete, or in this case, trying to provide a 100% safe way to do an immediate delete.
I'm not familiar enough with Qt's internals to know exactly why the crash occurs and I'm not expectng that from anyone on here.
What I'm hoping for is some feedback from developers who have experience building a foreign GUI framework (like X11...) on top of OS X and who know OS X and its frameworks much better than I do.
Am I right that doing an immediate delete of an object in response to a UI event is a bad idea because you cannot know in that event handler how many more events could arrive for that object and/or how many events are being processed? Or should it indeed be safe to do a direct delete as long as it's not in use in (or owned by) another thread?
Thanks in advance... :)
René
_______________________________________________
Do not post admin requests to the list. They will be ignored.
X11-users mailing list (email@hidden)
This email sent to email@hidden