[Interest] Strange undeletable QTemporaryFile. Is it a bug?

Thiago Macieira thiago.macieira at intel.com
Fri Aug 23 19:41:30 CEST 2013


On sexta-feira, 23 de agosto de 2013 14:33:06, Guido Seifert wrote:
> 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?

QTemporaryFile keeps the file open. You can't delete it with QFile::remove, you 
have to let QTemporaryFile do it. Or, you must destroy the QTemporaryFile 
object first, so it will actually close the file. Then you can delete it.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130823/0f67d692/attachment.sig>


More information about the Interest mailing list