[config] Guard overlay_params from the thread with mutex

pull/93/head
jackun 4 years ago
parent 34184abf2e
commit a0f5cb56a2
No known key found for this signature in database
GPG Key ID: 119DB3F1D05A9ED3

@ -23,8 +23,10 @@ void *fileChanged(void *params_void){
struct inotify_event *event = struct inotify_event *event =
(struct inotify_event *) &buffer[i]; (struct inotify_event *) &buffer[i];
i += EVENT_SIZE + event->len; i += EVENT_SIZE + event->len;
if (event->mask & IN_MODIFY) if (event->mask & IN_MODIFY) {
std::lock_guard<std::mutex> lk(nt->mutex);
parse_overlay_config(nt->params, getenv("MANGOHUD_CONFIG")); parse_overlay_config(nt->params, getenv("MANGOHUD_CONFIG"));
}
} }
i = 0; i = 0;
printf("File Changed\n"); printf("File Changed\n");

@ -1,10 +1,12 @@
#include <thread> #include <thread>
#include <mutex>
#include "overlay_params.h" #include "overlay_params.h"
struct notify_thread struct notify_thread
{ {
overlay_params *params = nullptr; overlay_params *params = nullptr;
bool quit = false; bool quit = false;
std::mutex mutex;
}; };
extern pthread_t fileChange; extern pthread_t fileChange;

@ -1296,9 +1296,11 @@ static void compute_swapchain_display(struct swapchain_data *data)
ImGui::SetCurrentContext(data->imgui_context); ImGui::SetCurrentContext(data->imgui_context);
ImGui::NewFrame(); ImGui::NewFrame();
{
position_layer(instance_data->params, data->window_size, data->width, data->height); scoped_lock lk(instance_data->notifier.mutex);
render_imgui(data->sw_stats, instance_data->params, data->window_size, data->width, data->height, true); position_layer(instance_data->params, data->window_size, data->width, data->height);
render_imgui(data->sw_stats, instance_data->params, data->window_size, data->width, data->height, true);
}
ImGui::PopStyleVar(3); ImGui::PopStyleVar(3);
ImGui::EndFrame(); ImGui::EndFrame();

Loading…
Cancel
Save