fix:the workspace data is null in a small probability

update

fix clang-format warn

no manual unlock
This commit is contained in:
DreamMaoMao 2023-12-23 21:38:19 +08:00
parent d2767fb84a
commit e64d66ab24
1 changed files with 6 additions and 0 deletions

View File

@ -6,7 +6,9 @@
#include <algorithm>
#include <charconv>
#include <memory>
#include <shared_mutex>
#include <string>
#include <thread>
#include <utility>
#include <variant>
@ -14,6 +16,8 @@
namespace waybar::modules::hyprland {
std::shared_mutex workspaceCreateSmtx;
int Workspaces::windowRewritePriorityFunction(std::string const &window_rule) {
// Rules that match against title are prioritized
// Rules that don't specify if they're matching against either title or class are deprioritized
@ -161,6 +165,7 @@ auto Workspaces::update() -> void {
}
// add workspaces that wait to be created
std::shared_lock<std::shared_mutex> workspaceCreateShareLock(workspaceCreateSmtx);
unsigned int currentCreateWorkspaceNum = 0;
for (Json::Value const &workspaceToCreate : m_workspacesToCreate) {
createWorkspace(workspaceToCreate);
@ -300,6 +305,7 @@ void Workspaces::onWorkspaceCreated(std::string const &payload) {
if (name == payload &&
(allOutputs() || m_bar.output->name == workspaceJson["monitor"].asString()) &&
(showSpecial() || !name.starts_with("special")) && !isDoubleSpecial(payload)) {
std::unique_lock<std::shared_mutex> workspaceCreateUniqueLock(workspaceCreateSmtx);
m_workspacesToCreate.push_back(workspaceJson);
break;
}