Kaynağa Gözat

linux-capture: Fix map-like behavior for watcher

The original PR missed assigning the `idx` variable in unregister. When
compiled without asserts this would silently not delete sources. Instead
correctly assign idx and skip unregistration if the source doesnt appear
registered.

fixes #6532
Kurt Kartaltepe 3 yıl önce
ebeveyn
işleme
fb639e303c
1 değiştirilmiş dosya ile 4 ekleme ve 0 silme
  1. 4 0
      plugins/linux-capture/xcomposite-input.c

+ 4 - 0
plugins/linux-capture/xcomposite-input.c

@@ -610,10 +610,13 @@ void watcher_unregister(xcb_connection_t *conn, struct xcompcap *s)
 			sizeof(struct reg_item), &watcher_registry.da, i);
 
 		if (item->src == s) {
+			idx = i;
 			win = item->win;
 			break;
 		}
 	}
+	if (idx == DARRAY_INVALID)
+		goto done;
 
 	da_erase(watcher_registry, idx);
 
@@ -636,6 +639,7 @@ void watcher_unregister(xcb_connection_t *conn, struct xcompcap *s)
 					     vals);
 	}
 
+done:
 	pthread_mutex_unlock(&watcher_lock);
 }