Hi,
just wondering if I'm doing something wrong or there really is a bug in
KDirWatch
(I'm on openSuse Leap 42.2, KF5 5.33.0)
From the docs I understand that when I call
KDirWatch::stopDirScan(dir);
... create files in the dir ...
KDirWatch::restartDirScan(dir)
it should not emit the dirty signal when I run this, right ?
Well, it does.
I've attached a small test.
When I modify the code and use stopScan() ... create ... startScan()
I still receive the dirty signal with the path to the file I created.
Only way it works without signal is
removeDir(dir) ... create ... addDir(dir)
Is this how it's supposed to work ?
--
Best regards/Schöne Grüße
Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?
() ascii ribbon campaign - against html e-mail
/\ - against proprietary attachments
Geschenkideen, Accessoires, Seifen, Kulinarisches: www.lillehus.at
cmake_minimum_required(VERSION 3.5)
project(dirwatch)
find_package(ECM 5.19 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
find_package(KF5CoreAddons)
add_executable(dirwatch main.cxx)
target_link_libraries(dirwatch KF5::CoreAddons)
#include <QCoreApplication>
#include <QFile>
#include <QTimer>
#include <QDebug>
#include <kdirwatch.h>
QString watchedDir;
KDirWatch *watch = 0;
class Object : public QObject
{
Q_OBJECT
public slots:
void createFile()
{
watch->stopDirScan(watchedDir);
//watch->stopScan();
//watch->removeDir(watchedDir);
QFile f(watchedDir + "/watched");
f.open(QIODevice::WriteOnly);
f.write("123");
f.close();
watch->restartDirScan(watchedDir);
//watch->startScan();
//watch->addDir(watchedDir);
}
void dirChanged(const QString &dir)
{
qDebug() << "dir changed" << dir;
}
};
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
watchedDir = QFile::decodeName(argv[1]);
watch = new KDirWatch;
watch->addDir(watchedDir);
Object o;
o.connect(watch, &KDirWatch::dirty, &o, &Object::dirChanged);
QTimer::singleShot(2000, &o, SLOT(createFile()));
return app.exec();
}
#include "main.moc"