mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-14 04:46:49 -05:00
Reduce logging for failed file watcher
This commit is contained in:
@@ -16,6 +16,7 @@ and this project somewhat adheres to [Semantic Versioning](https://semver.org/sp
|
||||
- Fix rare crash while quitting Porymap.
|
||||
- Fix exported images on macOS using a different color space than in Porymap.
|
||||
- Fix some `INCBIN` statements not being parsed correctly.
|
||||
- Fix excessive logging if Porymap fails to monitor all map files.
|
||||
|
||||
## [6.2.0] - 2025-08-08
|
||||
### Added
|
||||
|
||||
@@ -116,6 +116,9 @@ public:
|
||||
void setCustomAttributes(const QJsonObject &attributes) { m_customAttributes = attributes; }
|
||||
QJsonObject customAttributes() const { return m_customAttributes; }
|
||||
|
||||
static void setFileWatchingEnabled(bool enabled) { m_fileWatchingEnabled = enabled; }
|
||||
static bool isFileWatchingEnabled() { return m_fileWatchingEnabled; }
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_constantName;
|
||||
@@ -134,6 +137,7 @@ private:
|
||||
bool m_needsHealLocation = false;
|
||||
bool m_scriptsLoaded = false;
|
||||
bool m_loggedScriptsFileError = false;
|
||||
static bool m_fileWatchingEnabled;
|
||||
|
||||
QMap<Event::Group, QList<Event *>> m_events;
|
||||
QSet<Event *> m_ownedEvents; // for memory management
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <QImage>
|
||||
#include <QRegularExpression>
|
||||
|
||||
bool Map::m_fileWatchingEnabled = true;
|
||||
|
||||
Map::Map(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -149,7 +150,7 @@ QStringList Map::getScriptLabels(Event::Group group) {
|
||||
m_loggedScriptsFileError = true;
|
||||
}
|
||||
|
||||
if (porymapConfig.monitorFiles && !m_loggedScriptsFileError) {
|
||||
if (m_fileWatchingEnabled && !m_loggedScriptsFileError) {
|
||||
if (!m_scriptFileWatcher) {
|
||||
// Only create the file watcher when it's first needed (even an empty QFileSystemWatcher will consume system resources).
|
||||
// The other option would be for Porymap to have a single global QFileSystemWatcher, but that has complications of its own.
|
||||
|
||||
@@ -838,6 +838,7 @@ void Project::recordFileChange(const QString &filepath) {
|
||||
// When calling 'watchFile' we record failures rather than log them immediately.
|
||||
// We do this primarily to condense the warning if we fail to monitor any files.
|
||||
void Project::logFileWatchStatus() {
|
||||
Map::setFileWatchingEnabled(porymapConfig.monitorFiles);
|
||||
if (!this->fileWatcher)
|
||||
return;
|
||||
|
||||
@@ -851,6 +852,9 @@ void Project::logFileWatchStatus() {
|
||||
// on Windows and the project files are in WSL2. Rather than filling the log by
|
||||
// outputting a warning for every file, just log that we failed to monitor any of them.
|
||||
logWarn(QString("Failed to monitor project files"));
|
||||
|
||||
// Similarly, avoid logging a warning every time we open a map. We can assume that will also fail.
|
||||
Map::setFileWatchingEnabled(false);
|
||||
return;
|
||||
} else {
|
||||
logInfo(QString("Successfully monitoring %1/%2 project files").arg(numSuccessful).arg(numAttempted));
|
||||
|
||||
Reference in New Issue
Block a user