Skip to content

Commit

Permalink
fix:the workspace data is null in a small probability
Browse files Browse the repository at this point in the history
update
  • Loading branch information
DreamMaoMao committed Dec 23, 2023
1 parent d2767fb commit 9a4c1d5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/modules/hyprland/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
#include <string>
#include <utility>
#include <variant>
#include <shared_mutex>
#include <thread>

#include "util/regex_collection.hpp"

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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -300,7 +305,9 @@ 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);
workspaceCreateUniqueLock.unlock();
break;
}
}
Expand Down

0 comments on commit 9a4c1d5

Please sign in to comment.