[Interest] using QTemporaryFile for post-mortem debug logfiles?

Konstantin Tokarev annulen at yandex.ru
Mon May 22 16:35:07 CEST 2017

22.05.2017, 17:27, "René J.V. Bertin" <rjvbertin at gmail.com>:
> On Monday May 22 2017 15:08:34 Konrad Rosenbaum wrote:
> Hi,
>> This only works if the problem is a crash. Only a minor percentage of
> That's specifically the point here: post-mortem debug information.
>>>  I'm curious though, why does my QTemporaryFile trick to auto-remove only
>>>  empty files not work as expected?
>> Because the QTemporaryFile is not about a file being empty, its about a
>> file being temporary. It creates a normal file under a unique name and
>> normally deletes it when it is closed. This happens so you can safely use
> That doesn't answer my question, which is why setAutoRemove(true) has no effect when I call it just before closing the temp. file.

If you look at the implementation you'll find that close() for QTemporaryFile does not remove it, it's removed in the destructor only. You should really call remove() where you have setAutoRemove(true) and close()

> Maybe checking qTempFile->size() or even qTempFile->pos() against 0 doesn't give me the expected result, but then the why question moves to that fact.
>>  In either case QTemporaryFile does
>> not care a rat's furry backside about the content or lack of content of
>> the file... ;-)
> And well it shouldn't, if the file is empty ;)
>> PS: the time that it took us to discuss the pros and cons of a proper log
>> rotation scheme is not so much smaller than the time you need to implement
>> it ;-)
> Sure, that's often the case ... but just maybe now I'll be learning something 8-)
> R.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


More information about the Interest mailing list