mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06:07 +00:00
Fix initialization of change_layers (#907)
This commit is contained in:
parent
c924457e28
commit
1ea6db6045
|
@ -21,7 +21,12 @@ static std::vector<ImGui::Layer*> layers;
|
|||
// Update layers before rendering to allow layer changes to be applied during rendering.
|
||||
// Using deque to keep the order of changes in case a Layer is removed then added again between
|
||||
// frames.
|
||||
static std::deque<std::pair<bool, ImGui::Layer*>> change_layers;
|
||||
std::deque<std::pair<bool, ImGui::Layer*>>& GetChangeLayers() {
|
||||
static std::deque<std::pair<bool, ImGui::Layer*>>* change_layers =
|
||||
new std::deque<std::pair<bool, ImGui::Layer*>>;
|
||||
return *change_layers;
|
||||
}
|
||||
|
||||
static std::mutex change_layers_mutex{};
|
||||
|
||||
namespace ImGui {
|
||||
|
@ -113,15 +118,15 @@ bool ProcessEvent(SDL_Event* event) {
|
|||
void NewFrame() {
|
||||
{
|
||||
std::scoped_lock lock{change_layers_mutex};
|
||||
while (!change_layers.empty()) {
|
||||
const auto [to_be_added, layer] = change_layers.front();
|
||||
while (!GetChangeLayers().empty()) {
|
||||
const auto [to_be_added, layer] = GetChangeLayers().front();
|
||||
if (to_be_added) {
|
||||
layers.push_back(layer);
|
||||
} else {
|
||||
const auto [begin, end] = std::ranges::remove(layers, layer);
|
||||
layers.erase(begin, end);
|
||||
}
|
||||
change_layers.pop_front();
|
||||
GetChangeLayers().pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,12 +189,12 @@ void Render(const vk::CommandBuffer& cmdbuf, ::Vulkan::Frame* frame) {
|
|||
|
||||
void Layer::AddLayer(Layer* layer) {
|
||||
std::scoped_lock lock{change_layers_mutex};
|
||||
change_layers.emplace_back(true, layer);
|
||||
GetChangeLayers().emplace_back(true, layer);
|
||||
}
|
||||
|
||||
void Layer::RemoveLayer(Layer* layer) {
|
||||
std::scoped_lock lock{change_layers_mutex};
|
||||
change_layers.emplace_back(false, layer);
|
||||
GetChangeLayers().emplace_back(false, layer);
|
||||
}
|
||||
|
||||
} // namespace ImGui
|
||||
|
|
Loading…
Reference in a new issue