Procházet zdrojové kódy

mac-capture: Allow fetching source properties without source

Per OBS API documentation, `get_properties` can be used to get the
properties of a source, but also of a source type. The latter would
pass a NULL pointer for a given source.

This adds the necessary change to avoid crashing OBS by passing such
a null pointer.
PatTheMav před 3 roky
rodič
revize
6b56cfddb6
1 změnil soubory, kde provedl 33 přidání a 31 odebrání
  1. 33 31
      plugins/mac-capture/mac-screen-capture.m

+ 33 - 31
plugins/mac-capture/mac-screen-capture.m

@@ -986,41 +986,43 @@ static obs_properties_t *screen_capture_properties(void *data)
 		props, "show_hidden_windows",
 		obs_module_text("WindowUtils.ShowHidden"));
 
-	obs_property_set_modified_callback2(hidden, content_settings_changed,
-					    sc);
-
 	obs_properties_add_bool(props, "show_cursor",
 				obs_module_text("DisplayCapture.ShowCursor"));
 
-	switch (sc->capture_type) {
-	case 0: {
-		obs_property_set_visible(display_list, true);
-		obs_property_set_visible(window_list, false);
-		obs_property_set_visible(app_list, false);
-		obs_property_set_visible(empty, false);
-		obs_property_set_visible(hidden, false);
-		break;
-	}
-	case 1: {
-		obs_property_set_visible(display_list, false);
-		obs_property_set_visible(window_list, true);
-		obs_property_set_visible(app_list, false);
-		obs_property_set_visible(empty, true);
-		obs_property_set_visible(hidden, true);
-		break;
-	}
-	case 2: {
-		obs_property_set_visible(display_list, true);
-		obs_property_set_visible(app_list, true);
-		obs_property_set_visible(window_list, false);
-		obs_property_set_visible(empty, false);
-		obs_property_set_visible(hidden, true);
-		break;
-	}
-	}
+	if (sc) {
+		obs_property_set_modified_callback2(
+			hidden, content_settings_changed, sc);
+
+		switch (sc->capture_type) {
+		case 0: {
+			obs_property_set_visible(display_list, true);
+			obs_property_set_visible(window_list, false);
+			obs_property_set_visible(app_list, false);
+			obs_property_set_visible(empty, false);
+			obs_property_set_visible(hidden, false);
+			break;
+		}
+		case 1: {
+			obs_property_set_visible(display_list, false);
+			obs_property_set_visible(window_list, true);
+			obs_property_set_visible(app_list, false);
+			obs_property_set_visible(empty, true);
+			obs_property_set_visible(hidden, true);
+			break;
+		}
+		case 2: {
+			obs_property_set_visible(display_list, true);
+			obs_property_set_visible(app_list, true);
+			obs_property_set_visible(window_list, false);
+			obs_property_set_visible(empty, false);
+			obs_property_set_visible(hidden, true);
+			break;
+		}
+		}
 
-	obs_property_set_modified_callback2(empty, content_settings_changed,
-					    sc);
+		obs_property_set_modified_callback2(
+			empty, content_settings_changed, sc);
+	}
 
 	if (@available(macOS 13.0, *))
 		;