KTempFile->QTemporaryFile

George Staikos staikos at kde.org
Sun Sep 10 16:36:29 BST 2006


On Sunday 10 September 2006 11:14, Jaison Lee wrote:
> One of the items in the kdelibs TODO is:
>
> - KDE 4: Check if QTemporaryFile is good enough to dump KTempFile
>   (Albert Astals Cid)
>
> I've been looking at this recently along with Will Entriken.
> QTemporaryFile is certainly capable of doing everything KTempFile does
> and more, and it is probably worth the effort of making a few changes
> to increase consistency between the APIs. There are a few caveats,
> however:
>
> * KTempFile defaults to ~/.kde/tmp-${HOSTNAME} whereas QTemporaryFile
> defaults to /tmp (or /var/tmp)

  This is a critical difference.  We need the old behavior.

> * KTempFile does not autoremove by default whereas QTemporaryFile does.

  This is bound to introduce subtle bugs.

> * KTempFile HAS-A QFile whereas QTemporaryFile IS-A QFile, which just
> makes some porting less simple than a search-and-replace.

  This is easy.  We can make a compat function that returns "this".

> For all these reasons, I think we should create a new very small class
> called KTemporaryFile that inherits from QTemporaryFile. It will be in
> charge of setting the desired tmp directory, as well as setting
> autoremove false (if we decide we want to keep that behaviour). It
> will also provide a good place to put equivalents of the textStream()
> and dataStream() functions which I think will be handy shortcuts and
> make porting a bit easier.
>
> My plan then would be:
>
> Step 1) Create KTemporaryFile and mark KTempFile deprecated.
> Step 2) Port all existing KTempFiles to KTemporaryFile.
> Step 3) Remove KTempFile.
>
> This will provide Will and I ample time to complete step 2, while
> making sure that the codebase remains able to be compiled.
>
> So how does this sound to everyone? Does this look like something
> worth doing? Any comments on my overall plan? Should KTemporaryFile
> still default autoRemove to false even though QTemporaryFile defaults
> true? (Personally I would say no; take the Qt default in this case.)

  Sounds like it could work if it addresses the above concerns.

-- 
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/




More information about the kde-core-devel mailing list