Prechádzať zdrojové kódy

UI: Fix case where cef func may not be present

Due to a particular... plugin we all know and love, the new
QCefWidget::executeJavascript() function may not actually be present as
it should be. So, we have to verify that it's available, and only use it
in that case.
Lain 2 rokov pred
rodič
commit
78cb2aa361

+ 4 - 2
UI/window-basic-main.cpp

@@ -116,6 +116,7 @@ struct QCefCookieManager;
 
 QCef *cef = nullptr;
 QCefCookieManager *panel_cookies = nullptr;
+bool cef_js_avail = false;
 
 void DestroyPanelCookieManager();
 
@@ -2022,6 +2023,7 @@ void OBSBasic::OBSInit()
 
 #ifdef BROWSER_AVAILABLE
 	cef = obs_browser_init_panel();
+	cef_js_avail = cef && obs_browser_qcef_version() >= 3;
 #endif
 
 	OBSDataAutoRelease obsData = obs_get_private_data();
@@ -8493,7 +8495,7 @@ YouTubeAppDock *OBSBasic::GetYouTubeAppDock()
 
 void OBSBasic::NewYouTubeAppDock()
 {
-	if (!cef)
+	if (!cef_js_avail)
 		return;
 
 	if (youtubeAppDock)
@@ -8504,7 +8506,7 @@ void OBSBasic::NewYouTubeAppDock()
 
 void OBSBasic::DeleteYouTubeAppDock()
 {
-	if (!cef)
+	if (!cef_js_avail)
 		return;
 
 	if (youtubeAppDock)

+ 2 - 0
UI/window-basic-main.hpp

@@ -1267,6 +1267,8 @@ public:
 #endif
 };
 
+extern bool cef_js_avail;
+
 class SceneRenameDelegate : public QStyledItemDelegate {
 	Q_OBJECT
 

+ 2 - 2
UI/window-basic-settings-stream.cpp

@@ -771,7 +771,7 @@ void OBSBasicSettings::on_connectAccount_clicked()
 	if (!!auth) {
 		OnAuthConnected();
 #ifdef YOUTUBE_ENABLED
-		if (cef && IsYouTubeService(service)) {
+		if (cef_js_avail && IsYouTubeService(service)) {
 			if (!main->GetYouTubeAppDock()) {
 				main->NewYouTubeAppDock();
 			}
@@ -822,7 +822,7 @@ void OBSBasicSettings::on_disconnectAccount_clicked()
 	ui->connectedAccountText->setVisible(false);
 
 #ifdef YOUTUBE_ENABLED
-	if (cef && IsYouTubeService(service)) {
+	if (cef_js_avail && IsYouTubeService(service)) {
 		if (!main->GetYouTubeAppDock()) {
 			main->NewYouTubeAppDock();
 		}

+ 1 - 1
UI/window-basic-settings.cpp

@@ -4248,7 +4248,7 @@ void OBSBasicSettings::on_listWidget_itemSelectionChanged()
 void OBSBasicSettings::UpdateYouTubeAppDockSettings()
 {
 #if defined(BROWSER_ENABLED) && defined(YOUTUBE_ENABLED)
-	if (cef) {
+	if (cef_js_avail) {
 		std::string service = ui->service->currentText().toStdString();
 		if (IsYouTubeService(service)) {
 			if (!main->GetYouTubeAppDock()) {

+ 2 - 2
UI/window-dock-youtube-app.cpp

@@ -50,7 +50,7 @@ YouTubeAppDock::~YouTubeAppDock()
 
 bool YouTubeAppDock::IsYTServiceSelected()
 {
-	if (!cef)
+	if (!cef_js_avail)
 		return false;
 
 	obs_service_t *service_obj = OBSBasic::Get()->GetService();
@@ -429,7 +429,7 @@ YoutubeApiWrappers *YouTubeAppDock::GetYTApi()
 
 void YouTubeAppDock::CleanupYouTubeUrls()
 {
-	if (!cef)
+	if (!cef_js_avail)
 		return;
 
 	static constexpr const char *YOUTUBE_VIDEO_URL =

+ 1 - 1
plugins/obs-browser

@@ -1 +1 @@
-Subproject commit 291464d6988083411e7369fc53eba6d5ef07ff67
+Subproject commit 7fe8b0b16ed092cecec825105d1ebabd0e2167c2