--Boundary-03=_8HCYAHma2XWL/ll Content-Type: multipart/mixed; boundary="Boundary-01=_4HCYAxH4efVhPEc" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_4HCYAxH4efVhPEc Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi, 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=20 image if the image wasn't modified in KView. But whenever the image was modified in KView and you call "Save" the=20 slotFileDirty slot is called (asynchronous). Problem: KDirWatch apparently= =20 emits dirty 18 times. I now have a workaround for KView that disables the slotFileDirty for 100ms= =20 with a singleShot timer. But this is butt ugly so if there's any way we cou= ld=20 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=20 testcase.cpp -o testcase =2E/testcase testfile I get 271 dirty notifications with that program. :-( =2D-=20 C'ya Matthias ________________________________________________________ Matthias Kretz (Germany) <>< http://Vir.homeip.net/ MatthiasKretz@gmx.net, kretz@kde.org, Matthias.Kretz@urz.uni-heidelberg.de --Boundary-01=_4HCYAxH4efVhPEc Content-Type: text/x-c++src; charset="us-ascii"; name="testcase.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="testcase.cpp" #include #include #include #include #include #include #include #include class Test : public QObject { Q_OBJECT public: Test( const KURL & url ) { dirwatch = new KDirWatch( this ); connect( dirwatch, SIGNAL( dirty( const QString & ) ), SLOT( dirty( const QString & ) ) ); QTimer::singleShot( 0, this, SLOT( openFile() ) ); filename = url.path(); } ~Test() { delete dirwatch; } private slots: void openFile() { file.setName( filename ); file.open( IO_ReadWrite ); dirwatch->addFile( filename ); QTimer::singleShot( 100, this, SLOT( saveFile() ) ); } void saveFile() { for( int i = 0; i < 4 * 1024; ++i ) file.writ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o\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\n" "foo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\n" "foo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\n" "foo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\nfoo\n" , 1024 ); file.close(); QTimer::singleShot( 2000, kapp, SLOT( quit() ) ); } void dirty( const QString & file ) { static int count = 0; ++count; kdDebug() << k_funcinfo << file << " " << count << endl; } private: QString filename; QFile file; KDirWatch * dirwatch; }; static KCmdLineOptions options[] = { { "+URL", "testcase file", 0 }, KCmdLineLastOption }; int main( int argc, char ** argv ) { KCmdLineArgs::init( argc, argv, "test", "test", "test", "1.0" ); KCmdLineArgs::addCmdLineOptions( options ); KApplication app; KCmdLineArgs * args = KCmdLineArgs::parsedArgs(); if( ! args->url( 0 ).isEmpty() ) { Test * test = new Test( args->url( 0 ) ); return app.exec(); } } // vim: sw=4 ts=4 #include "testcase.moc" --Boundary-01=_4HCYAxH4efVhPEc-- --Boundary-03=_8HCYAHma2XWL/ll Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBAYCH8yg4WnCj6OIoRAq9kAKCHilECihL0kwQhonhnRr+PX6iQ7QCePvwa XBG7jzwGfVIr0G1LyrnXQYE= =O4ov -----END PGP SIGNATURE----- --Boundary-03=_8HCYAHma2XWL/ll--