KTar + KTempFile + QFilePrivate::openExternalFile

Nicolas Goutte nicolasg at snafu.de
Sat Sep 17 09:01:33 BST 2005


On Saturday 17 September 2005 02:32, Sascha Cunz wrote:
> Hi Roberto,
> hi kde-core-devels,
>
> i do now know, why KTar does not work.
>
> This is because of KTempFile::file() returns a pointer to a QFile for which
> QFile::fileName() will return an empty string.
>
> This in turn is due to this code:
>
> QFile* KTempFile::file()
> {
>    [...]
>    mFile = new QFile();
>    mFile->setFileName( name() );
>    mFile->open(QIODevice::ReadWrite, mStream);
>    return mFile;
> }
>
> The problem is: setFileName will create a QBufferedFSFileEngine. In this fe
> it will set d_ptr->fileName to what KTempFile::name() has returned. The
> following QFile::open(OpenMode, FILE*) call will then delete the
> QBufferedFSFileEngine again. And create a new one. Which has no name.
> We cannot switch both lines, because the second QBufferedFSFileEngine will
> be marked as "isOpen" and setFileName on the QFile will fail.
>
> KTar then furhter assumes, that the retuned QFile has to be closed, which
> is not posible according to Qt3.3 and Qt4.0 docs. However, KTar calls
> QFile::close, then later KTar::KTarPrivate::fillTempFile where the QFile is
> closed again (why ever?). No it opens the file for write-only. This is
> where Qt barks, because the QFile has no fileName() attached to it.

Does this mean that you have the same problem with KDE 3.5.x with Qt 3.3.x 
too? (I have never seen such a problem.)

(...)

Have a nice day!





More information about the kde-core-devel mailing list