QFileSystemWatcher 在单例类中,不能指定父类,不能用智能指针,否则会释放不掉,发生资源竞争。
要这样释放。

    QObject::connect(qApp, SIGNAL(aboutToQuit()), m_pCupsFileWatcher, SLOT(deleteLater()));

这是源码中的注意点

/*!
    Destroys the file system watcher.
    \note To avoid deadlocks on shutdown, all instances of QFileSystemWatcher
    need to be destroyed before QCoreApplication. Note that passing
    QCoreApplication::instance() as the parent object when creating
    QFileSystemWatcher is not sufficient.
*/
QFileSystemWatcher::~QFileSystemWatcher()