[Interest] Strange undeletable QTemporaryFile. Is it a bug?
wargand at gmx.de
Fri Aug 23 14:33:06 CEST 2013
Hi, I just had some trouble with a strange undeletable QTemporaryFile. Of course only under Windows. Under Linux the code worked perfectly. Now I know, that Windows has troubles to remove open files, but this was not the problem (I think).
I created a QTemporaryFile and disabled autoremove (setAutoRemove(false)). I needed the file for a while in several other places. I always closed it after usage. When I finally was done with it, I tried to remove it. Tough luck. QFile::remove(<filename>) or the non-static version returned false. Errorstring: 'unknown error', which usually means no error at all.
Of course I thought, that the problem is somewhere in my code, however, here is what I did: I created a QTemporaryFile object just to get a unique filename. I dropped the object at once, I did not use it. But with the unique filename I created a normal QFile. This I passed around exactly like I did with the QTemporaryFile. Actually I always passed only the filename around, never the file object itself. My functions opened and closed it. And this file I could delete without problems after I did not need it anymore.
I think, if I did some coding error in one of my functions, it shouldn't have made a difference whether the filename belonged to a file, which was created via QTemporaryFile object, or via QFile object.
What do you think? A but, or do I overlook something?
More information about the Interest