Browse Source

UI: Remove whitespace from end of autconfig stream key

Because ?bandwidthtest is being appended to the end, it would bypass
normal whitespace removal, causing the stream key to fail.
jp9000 8 years ago
parent
commit
fa09e6743d
1 changed files with 14 additions and 1 deletions
  1. 14 1
      UI/window-basic-auto-config-test.cpp

+ 14 - 1
UI/window-basic-auto-config-test.cpp

@@ -146,6 +146,17 @@ void AutoConfigTestPage::GetServers(std::vector<ServerInfo> &servers)
 	obs_properties_destroy(ppts);
 	obs_properties_destroy(ppts);
 }
 }
 
 
+static inline void string_depad_key(string &key)
+{
+	while (!key.empty()) {
+		char ch = key.back();
+		if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
+			key.pop_back();
+		else
+			break;
+	}
+}
+
 void AutoConfigTestPage::TestBandwidthThread()
 void AutoConfigTestPage::TestBandwidthThread()
 {
 {
 	bool connected = false;
 	bool connected = false;
@@ -205,8 +216,10 @@ void AutoConfigTestPage::TestBandwidthThread()
 	obs_data_release(output_settings);
 	obs_data_release(output_settings);
 
 
 	std::string key = wiz->key;
 	std::string key = wiz->key;
-	if (wiz->service == AutoConfig::Service::Twitch)
+	if (wiz->service == AutoConfig::Service::Twitch) {
+		string_depad_key(key);
 		key += "?bandwidthtest";
 		key += "?bandwidthtest";
+	}
 
 
 	obs_data_set_string(service_settings, "service",
 	obs_data_set_string(service_settings, "service",
 			wiz->serviceName.c_str());
 			wiz->serviceName.c_str());