Fix segfault when switching monitors with kmsgrab

This commit is contained in:
loki
2021-08-08 13:42:25 +02:00
parent 13d0106feb
commit 24403cdd25
4 changed files with 14 additions and 12 deletions
+8 -5
View File
@@ -675,11 +675,10 @@ void captureThread(
img.reset();
}
// Some classes of display cannot have multiple instances at once
disp.reset();
// display_wp is modified in this thread only
while(!display_wp->expired()) {
// Wait for the other shared_ptr's of display to be destroyed.
// New displays will only be created in this thread.
while(display_wp->use_count() != 1) {
std::this_thread::sleep_for(100ms);
}
@@ -695,7 +694,11 @@ void captureThread(
return;
}
display_wp = disp;
{
auto lg = display_wp.lock();
display_wp = disp;
}
// Re-allocate images
for(auto &img : imgs) {
img = disp->alloc_img();