QDir
uses synchronous file API. When underlying file system freezes, it freezes too. There are 2 options to avoid GUI freeze:
1.
Move file operations to a separate thread. Use signal/slot connection to request the thread to perform QDir::exists
call and to pass the result back into the GUI thread. If the filesystem freezes, only the background thread will be frozen. GUI will still operate.
2.
Use a library that uses asynchronous file API. Any request made by this library will return control flow to your app immediately. The result will be passed to the callback function. See this question for available options.