f31522130f
Build system (5 gaps hardened): - COOKBOOK_OFFLINE defaults to true (fork-mode) - normalize_patch handles diff -ruN format - New 'repo validate-patches' command (25/25 relibc patches) - 14 patched Qt/Wayland/display recipes added to protected list - relibc archive regenerated with current patch chain Boot fixes (fixable): - Full ISO EFI partition: 16 MiB → 1 MiB (matches mini, BIOS hardcoded 2 MiB offset) - D-Bus system bus: absolute /usr/bin/dbus-daemon path (was skipped) - redbear-sessiond: absolute /usr/bin/redbear-sessiond path (was skipped) - daemon framework: silenced spurious INIT_NOTIFY warnings for oneshot_async services (P0-daemon-silence-init-notify.patch) - udev-shim: demoted INIT_NOTIFY warning to INFO (expected for oneshot_async) - relibc: comprehensive named semaphores (sem_open/close/unlink) replacing upstream todo!() stubs - greeterd: Wayland socket timeout 15s → 30s (compositor DRM wait) - greeter-ui: built and linked (header guard unification, sem_compat stubs removed) - mc: un-ignored in both configs, fixed glib/libiconv/pcre2 transitive deps - greeter config: removed stale keymapd dependency from display/greeter services - prefix toolchain: relibc headers synced, _RELIBC_STDLIB_H guard unified Unfixable (diagnosed, upstream): - i2c-hidd: abort on no-I2C-hardware (QEMU) — process::exit → relibc abort - kded6/greeter-ui: page fault 0x8 — Qt library null deref - Thread panics fd != -1 — Rust std library on Redox - DHCP timeout / eth0 MAC — QEMU user-mode networking - hwrngd/thermald — no hardware RNG/thermal in VM - live preload allocation — BIOS memory fragmentation, continues on demand
126 lines
3.5 KiB
C++
126 lines
3.5 KiB
C++
// Copyright (C) 2018 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#include "qmlpreviewfilesystemwatcher.h"
|
|
|
|
#include <QtCore/qdebug.h>
|
|
#include <QtCore/qdir.h>
|
|
#include <QtCore/qfilesystemwatcher.h>
|
|
|
|
QmlPreviewFileSystemWatcher::QmlPreviewFileSystemWatcher(QObject *parent) :
|
|
QObject(parent), m_watcher(new QFileSystemWatcher(this))
|
|
{
|
|
connect(m_watcher, &QFileSystemWatcher::fileChanged,
|
|
this, &QmlPreviewFileSystemWatcher::fileChanged);
|
|
connect(m_watcher, &QFileSystemWatcher::directoryChanged,
|
|
this, &QmlPreviewFileSystemWatcher::onDirectoryChanged);
|
|
}
|
|
|
|
bool QmlPreviewFileSystemWatcher::watchesFile(const QString &file) const
|
|
{
|
|
return m_files.contains(file);
|
|
}
|
|
|
|
void QmlPreviewFileSystemWatcher::addFile(const QString &file)
|
|
{
|
|
if (watchesFile(file)) {
|
|
qWarning() << "FileSystemWatcher: File" << file << "is already being watched.";
|
|
return;
|
|
}
|
|
|
|
QStringList toAdd(file);
|
|
m_files.insert(file);
|
|
|
|
const QString directory = QFileInfo(file).path();
|
|
const int dirCount = ++m_directoryCount[directory];
|
|
Q_ASSERT(dirCount > 0);
|
|
|
|
if (dirCount == 1)
|
|
toAdd.append(directory);
|
|
|
|
m_watcher->addPaths(toAdd);
|
|
}
|
|
|
|
void QmlPreviewFileSystemWatcher::removeFile(const QString &file)
|
|
{
|
|
WatchEntrySetIterator it = m_files.find(file);
|
|
if (it == m_files.end()) {
|
|
qWarning() << "FileSystemWatcher: File" << file << "is not watched.";
|
|
return;
|
|
}
|
|
|
|
QStringList toRemove(file);
|
|
m_files.erase(it);
|
|
m_watcher->removePath(file);
|
|
|
|
const QString directory = QFileInfo(file).path();
|
|
const int dirCount = --m_directoryCount[directory];
|
|
Q_ASSERT(dirCount >= 0);
|
|
|
|
if (!dirCount)
|
|
toRemove.append(directory);
|
|
|
|
m_watcher->removePaths(toRemove);
|
|
}
|
|
|
|
bool QmlPreviewFileSystemWatcher::watchesDirectory(const QString &directory) const
|
|
{
|
|
return m_directories.contains(directory);
|
|
}
|
|
|
|
void QmlPreviewFileSystemWatcher::addDirectory(const QString &directory)
|
|
{
|
|
if (watchesDirectory(directory)) {
|
|
qWarning() << "FileSystemWatcher: Directory" << directory << "is already being watched.";
|
|
return;
|
|
}
|
|
|
|
m_directories.insert(directory);
|
|
const int count = ++m_directoryCount[directory];
|
|
Q_ASSERT(count > 0);
|
|
|
|
if (count == 1)
|
|
m_watcher->addPath(directory);
|
|
}
|
|
|
|
void QmlPreviewFileSystemWatcher::removeDirectory(const QString &directory)
|
|
{
|
|
WatchEntrySetIterator it = m_directories.find(directory);
|
|
if (it == m_directories.end()) {
|
|
qWarning() << "FileSystemWatcher: Directory" << directory << "is not watched.";
|
|
return;
|
|
}
|
|
|
|
m_directories.erase(it);
|
|
|
|
const int count = --m_directoryCount[directory];
|
|
Q_ASSERT(count >= 0);
|
|
|
|
if (!count)
|
|
m_watcher->removePath(directory);
|
|
}
|
|
|
|
void QmlPreviewFileSystemWatcher::onDirectoryChanged(const QString &path)
|
|
{
|
|
if (m_directories.contains(path))
|
|
emit directoryChanged(path);
|
|
|
|
QStringList toReadd;
|
|
const QDir dir(path);
|
|
for (const QFileInfo &entry : dir.entryInfoList(QDir::Files)) {
|
|
const QString file = entry.filePath();
|
|
if (m_files.contains(file))
|
|
toReadd.append(file);
|
|
}
|
|
|
|
if (!toReadd.isEmpty()) {
|
|
const QStringList remove = m_watcher->addPaths(toReadd);
|
|
for (const QString &rejected : remove)
|
|
toReadd.removeOne(rejected);
|
|
|
|
// If we've successfully added the file, that means it was deleted and replaced.
|
|
for (const QString &reAdded : std::as_const(toReadd))
|
|
emit fileChanged(reAdded);
|
|
}
|
|
}
|