Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/config/config_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ vkShade::ConfigStore::ConfigStore(Type type)

void vkShade::ConfigStore::clear()
{
m_watcher->unwatch();
if (m_watcher)
m_watcher->unwatch();
m_currentFile = std::filesystem::path{};
m_config.clear();
m_observer.notify_all(*this);
Expand Down Expand Up @@ -73,7 +74,8 @@ bool vkShade::ConfigStore::load(std::filesystem::path filePath)
m_observer.notify_all(*this);

m_currentFile = filePath;
m_watcher->watch(filePath);
if (m_watcher)
m_watcher->watch(filePath);

Logger::info("Loaded {} file: {}", m_typeString, filePath.string());
return true;
Expand All @@ -90,7 +92,8 @@ bool vkShade::ConfigStore::save(std::filesystem::path filePath)
}

// Unwatch so we don't automatically reload
m_watcher->unwatch();
if (m_watcher)
m_watcher->unwatch();

// Group by section
std::map<std::string, std::vector<std::pair<std::string, std::string>>> sections;
Expand Down Expand Up @@ -143,7 +146,8 @@ bool vkShade::ConfigStore::save(std::filesystem::path filePath)
Logger::info("Saved {} file: {}", m_typeString, filePath.string());

m_currentFile = filePath;
m_watcher->watch(filePath);
if (m_watcher)
m_watcher->watch(filePath);

return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/platform/file_watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace vkShade::Platform
return std::make_unique<FileWatcherImpl>();
}
catch (const std::system_error& e) {
Logger::error("Failed to create file watcher: {}", e.what());
Logger::warn("File watcher unavailable, changed files will not be reloaded automatically: {}",
e.what());
return nullptr;
}
}
Expand Down