KDirWatch emitting dirty signal many times for one change

Matthias Kretz kretz at kde.org
Tue Mar 23 11:39:36 GMT 2004


I have a problem with KDirWatch that I just cannot find a way to work with:

In KView the currently shown image is added to the dir watcher:
m_pFileWatch->addFile( m_file );
The dirty signal is connected to slotFileDirty which does a reload of the 
image if the image wasn't modified in KView.

But whenever the image was modified in KView and you call "Save" the 
slotFileDirty slot is called (asynchronous). Problem: KDirWatch apparently 
emits dirty 18 times.

I now have a workaround for KView that disables the slotFileDirty for 100ms 
with a singleShot timer. But this is butt ugly so if there's any way we could 
fix this the right way (TM) I'd be very happy. :-)

I just wrote a testcase to illustrate the point. Do the following:
moc testcase.cpp > testcase.moc
g++ -L$KDEDIR/lib -L$QTDIR/lib -lkio -I$QTDIR/include -I$KDEDIR/include 
testcase.cpp -o testcase
./testcase testfile

I get 271 dirty notifications with that program. :-(

Matthias Kretz (Germany)                          <><
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase.cpp
Type: text/x-c++src
Size: 2975 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040323/e7eb874f/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040323/e7eb874f/attachment.sig>

More information about the kde-core-devel mailing list