[PATCH] BUG 167388 inconsistency in ~/.kde4/share/config/trashrc
David Faure
faure at kde.org
Mon Sep 14 15:16:43 BST 2009
[Too much cross-posting, removing kde-devel from the CC list]
On Wednesday 02 September 2009, 潘卫平(Peter Pan) wrote:
===================================================================
> --- trashimpl.cpp (revision 1018673)
> +++ trashimpl.cpp (working copy)
> @@ -771,6 +771,7 @@
>
> void TrashImpl::fileAdded()
> {
> + m_config.reparseConfiguration();
> KConfigGroup group = m_config.group( "Status" );
> if ( group.readEntry( "Empty", true) == true ) {
> group.writeEntry( "Empty", false );
This one makes sense indeed. Before reading we have to re-read from
disk. Well, ideally only if it changed, so another fix would be to use
KDirWatch on ktrashrc.
> @@ -784,6 +785,7 @@
> void TrashImpl::fileRemoved()
> {
> if ( isEmpty() ) {
> + m_config.reparseConfiguration();
> KConfigGroup group = m_config.group( "Status" );
> group.writeEntry( "Empty", true );
> m_config.sync();
This one is not necessary. There's no point in reparsing if we're only writing
and not reading, is there? We'll overwrite any changes anyway.
> But if more than one kio_trash are created, inconsistency may occur,
This is indeed true, and Tobias' answer is valid for that part.
I don't think KInterProcessLock removes the need for the reparseConfiguration
before reading, though, if that's what Tobias implied -- but I don't think it
was what he implied ;).
> reparseConfiguration is expensive,
Yes, because of kdeglobals. We should turn m_config into a SimpleConfig, in
fact, so that it only reads the local trashrc and not any kdeglobals or global
trashrc. I'll do that, you commit the reparseConfiguration and close the bug?
Thanks!
Tobias: hmm I just noticed that you used "ktrashrc" for the user settings,
while the empty/not-empty flag is in "trashrc", for a reason I cannot remember.
On one hand we should probably merge that so that it's less confusing, on the
other hand it would make reparseConfiguration more expensive again ;-)
--
David Faure, faure at kde.org, sponsored by Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel
mailing list