Details
-
Suggestion
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
4.7.1
-
None
Description
The problem is the following:
The requirements:
1) a library wants to use QFileSystemWatcher (created from the heap)
2) the library needs to be explicitly unloadable, and when unloaded explicitly, it must clear all resources
Other info:
3) It seems that QFileSystemWatcher must be deleted before QCoreApplication. (This is not documented!)
E.g., the following program hangs (Qt version 4.7.0~git20100827-0maemo1+0m6):
int main(int argc, char **argv) { QCoreApplication* app = new QCoreApplication(argc, argv); QFileSystemWatcher watcher = new QFileSystemWatcher(); watcher->addPath("something"); qDebug() << "deleting app"; delete app; qDebug() << "deleting watcher"; delete watcher; qDebug() << "this is never seen"; return 0; }
(This might be a bug in itself.)
The consequences:
4) The library works around this by installing a post routine with qAddPostRoutine, and the post routine will delete the QFileSystemWatcher.
5) When unloaded, the library needs to remove the post routine. (If it doesn't, the application will crash when it tries to execute it, since the library has been unloaded explicitly before.) But qRemovePostRoutine is undocumented.
6) In qAddPostRoutine, you instruct library users to use a static object instead of it. But it doesn't work in this case: it would destroy the "library is not explicitly unloaded before ~QCoreApplication" use case. In that case, ~QCoreApplication is run before the destructor of the static object, resulting in a hang when the static object is destroyed.
Information needed:
- is 3) a bug?
- document the details needed to make these scenarios (the library may or may not be unloaded explicitly) work properly with a library using QFileSystemWatcher