mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
frontend: Clean up unneeded conversions on YouTube dialog close
The strings (broadcast.id, stream.[id|name]) are stored as QString, converted to const char * by QT_TO_UTF8 in OBSYoutubeActions, implicitly converted back to QString because the OBSYoutubeActions::ok takes const QString &, only to be converted back to const char * by QT_TO_UTF8 in OBSBasic_YouTube and immediately implicitly turned into const std::strings, only to have .c_str() called on those to get their const char * again which is needed for libobs. This is insane. Let's just pass const std::string & and be happy.
This commit is contained in:
committed by
Ryan Foster
parent
e38e9f8070
commit
d208c0a128
@@ -527,14 +527,14 @@ void OBSYoutubeActions::InitBroadcast()
|
||||
} else {
|
||||
// Stream now usecase.
|
||||
blog(LOG_DEBUG, "New valid stream: %s", QT_TO_UTF8(stream.name));
|
||||
emit ok(QT_TO_UTF8(broadcast.id), QT_TO_UTF8(stream.id), QT_TO_UTF8(stream.name), true,
|
||||
true, true);
|
||||
emit ok(broadcast.id.toStdString(), stream.id.toStdString(), stream.name.toStdString(),
|
||||
true, true, true);
|
||||
Accept();
|
||||
}
|
||||
} else {
|
||||
// Stream to precreated broadcast usecase.
|
||||
emit ok(QT_TO_UTF8(broadcast.id), QT_TO_UTF8(stream.id), QT_TO_UTF8(stream.name), autostart,
|
||||
autostop, true);
|
||||
emit ok(broadcast.id.toStdString(), stream.id.toStdString(), stream.name.toStdString(),
|
||||
autostart, autostop, true);
|
||||
Accept();
|
||||
}
|
||||
} else {
|
||||
@@ -577,8 +577,8 @@ void OBSYoutubeActions::ReadyBroadcast()
|
||||
thread->wait();
|
||||
|
||||
if (success) {
|
||||
emit ok(QT_TO_UTF8(broadcast.id), QT_TO_UTF8(stream.id), QT_TO_UTF8(stream.name), autostart, autostop,
|
||||
false);
|
||||
emit ok(broadcast.id.toStdString(), stream.id.toStdString(), stream.name.toStdString(), autostart,
|
||||
autostop, false);
|
||||
Accept();
|
||||
} else {
|
||||
// Fail.
|
||||
|
||||
@@ -33,8 +33,8 @@ class OBSYoutubeActions : public QDialog {
|
||||
std::unique_ptr<Ui::OBSYoutubeActions> ui;
|
||||
|
||||
signals:
|
||||
void ok(const QString &broadcast_id, const QString &stream_id, const QString &key, bool autostart,
|
||||
bool autostop, bool start_now);
|
||||
void ok(const std::string &broadcast_id, const std::string &stream_id, const std::string &key, bool autostart,
|
||||
bool autostop, bool startNow);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
@@ -1661,8 +1661,8 @@ private:
|
||||
|
||||
void YoutubeStreamCheck(const std::string &key);
|
||||
void ShowYouTubeAutoStartWarning();
|
||||
void YouTubeActionDialogOk(const QString &broadcast_id, const QString &stream_id, const QString &key,
|
||||
bool autostart, bool autostop, bool start_now);
|
||||
void YouTubeActionDialogOk(const std::string &broadcastId, const std::string &streamId, const std::string &key,
|
||||
bool autostart, bool autostop, bool startNow);
|
||||
#endif
|
||||
|
||||
void BroadcastButtonClicked();
|
||||
|
||||
@@ -32,21 +32,15 @@ using namespace std;
|
||||
extern bool cef_js_avail;
|
||||
|
||||
#ifdef YOUTUBE_ENABLED
|
||||
void OBSBasic::YouTubeActionDialogOk(const QString &broadcast_id, const QString &stream_id, const QString &key,
|
||||
bool autostart, bool autostop, bool start_now)
|
||||
void OBSBasic::YouTubeActionDialogOk(const std::string &broadcastId, const std::string &streamId,
|
||||
const std::string &key, bool autostart, bool autostop, bool startNow)
|
||||
{
|
||||
//blog(LOG_DEBUG, "Stream key: %s", QT_TO_UTF8(key));
|
||||
obs_service_t *service_obj = GetService();
|
||||
OBSDataAutoRelease settings = obs_service_get_settings(service_obj);
|
||||
|
||||
const std::string a_key = QT_TO_UTF8(key);
|
||||
obs_data_set_string(settings, "key", a_key.c_str());
|
||||
|
||||
const std::string b_id = QT_TO_UTF8(broadcast_id);
|
||||
obs_data_set_string(settings, "broadcast_id", b_id.c_str());
|
||||
|
||||
const std::string s_id = QT_TO_UTF8(stream_id);
|
||||
obs_data_set_string(settings, "stream_id", s_id.c_str());
|
||||
obs_data_set_string(settings, "key", key.c_str());
|
||||
obs_data_set_string(settings, "broadcast_id", broadcastId.c_str());
|
||||
obs_data_set_string(settings, "stream_id", streamId.c_str());
|
||||
|
||||
obs_service_update(service_obj, settings);
|
||||
autoStartBroadcast = autostart;
|
||||
@@ -55,7 +49,7 @@ void OBSBasic::YouTubeActionDialogOk(const QString &broadcast_id, const QString
|
||||
|
||||
emit BroadcastStreamReady(broadcastReady);
|
||||
|
||||
if (start_now)
|
||||
if (startNow)
|
||||
QMetaObject::invokeMethod(this, "StartStreaming");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user