Skip to content

Commit c94da59

Browse files
Fixes crash when user could click download on an asset before fully loaded.
1 parent 3f18c2f commit c94da59

File tree

7 files changed

+53
-17
lines changed

7 files changed

+53
-17
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function(setup_obs_lib_dependency target)
3434
endif()
3535
endfunction()
3636

37-
project(elgato-deeplinking VERSION 0.0.1)
37+
project(elgato-marketplace VERSION 0.0.2)
3838

3939
if(${CMAKE_PROJECT_NAME} STREQUAL "obs-studio")
4040
set(OBS_FRONTEND_API_NAME "frontend-api")

buildspec.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
},
3636
"platformConfig": {
3737
"macos": {
38-
"bundleId": "com.elgato.deeplinking"
38+
"bundleId": "com.elgato.marketplace-plugin"
3939
}
4040
},
41-
"name": "elgato-deeplinking",
42-
"displayName": "Elgato Deep Linking",
43-
"version": "0.0.1",
41+
"name": "elgato-marketplace",
42+
"displayName": "Elgato Marketplace Plugin",
43+
"version": "0.0.2",
4444
"author": "Elgato",
4545
"website": "https://elgato.com",
4646
"email": "support@elgato.com",

src/elgato-cloud-data.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ void ElgatoCloud::_Listen()
111111
listen_on_pipe("elgato_cloud", [this](std::string d) {
112112
obs_log(LOG_INFO, "Got Deeplink %s", d.c_str());
113113
if (d.find("elgatoobs://auth") == 0) {
114+
if (mainWindowOpen && window) {
115+
QMetaObject::invokeMethod(
116+
QCoreApplication::instance()->thread(),
117+
[this]() {
118+
window->setLoading();
119+
window->show();
120+
window->raise();
121+
window->activateWindow();
122+
});
123+
}
124+
114125
obs_log(LOG_INFO, "auth detected");
115126
std::unique_lock lock(m);
116127
if (!authorizing) {
@@ -250,10 +261,19 @@ void ElgatoCloud::LoadPurchasedProducts()
250261
if (!loggedIn) {
251262
return;
252263
}
253-
264+
loading = true;
254265
// Todo- only refresh token if it needs refreshing
255266
_TokenRefresh(false);
256267

268+
if (mainWindowOpen && window) {
269+
QMetaObject::invokeMethod(
270+
QCoreApplication::instance()->thread(),
271+
[this]() {
272+
window->setLoading();
273+
});
274+
}
275+
276+
257277
auto api = MarketplaceApi::getInstance();
258278
std::string api_url = api->gatewayUrl();
259279
api_url += "/my-products?extension=overlays&offset=0&limit=100";
@@ -362,6 +382,9 @@ void ElgatoCloud::_LoadUserData(bool loadData)
362382
QMetaObject::invokeMethod(
363383
QCoreApplication::instance()->thread(),
364384
[this, loadData]() {
385+
if (loadData) {
386+
loading = true;
387+
}
365388
window->setLoggedIn();
366389
if (loadData) {
367390
LoadPurchasedProducts();

src/elgato-cloud-window.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ DownloadButton::DownloadButton(QWidget *parent) : QWidget(parent)
102102
_downloadButton->setToolTip("Click to Download");
103103
std::string downloadIconPath = imageBaseDir + "download.svg";
104104
std::string downloadIconHoverPath = imageBaseDir + "download_hover.svg";
105-
std::string downloadIconDisabledPath = imageBaseDir + "download_hover.svg";
105+
std::string downloadIconDisabledPath =
106+
imageBaseDir + "download_hover.svg";
106107
QString buttonStyle = EIconHoverDisabledButtonStyle;
107108
buttonStyle.replace("${img}", downloadIconPath.c_str());
108109
buttonStyle.replace("${hover-img}", downloadIconHoverPath.c_str());
109-
buttonStyle.replace("${disabled-img}", downloadIconDisabledPath.c_str());
110+
buttonStyle.replace("${disabled-img}",
111+
downloadIconDisabledPath.c_str());
110112
_downloadButton->setFixedSize(24, 24);
111113
_downloadButton->setStyleSheet(buttonStyle);
112114
_downloadButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@@ -247,7 +249,8 @@ WindowToolBar::WindowToolBar(QWidget *parent) : QWidget(parent)
247249
std::string settingsIconHoverPath = imageBaseDir + "settings_hover.svg";
248250
QString settingsButtonStyle = EIconHoverButtonStyle;
249251
settingsButtonStyle.replace("${img}", settingsIconPath.c_str());
250-
settingsButtonStyle.replace("${hover-img}", settingsIconHoverPath.c_str());
252+
settingsButtonStyle.replace("${hover-img}",
253+
settingsIconHoverPath.c_str());
251254
_settingsButton->setFixedSize(24, 24);
252255
_settingsButton->setMaximumHeight(24);
253256
_settingsButton->setStyleSheet(settingsButtonStyle);
@@ -260,7 +263,8 @@ WindowToolBar::WindowToolBar(QWidget *parent) : QWidget(parent)
260263
_storeButton = new QPushButton(this);
261264
_storeButton->setToolTip("Go to Elgato Marketplace");
262265
std::string storeIconPath = imageBaseDir + "marketplace-logo.svg";
263-
std::string storeIconHoverPath = imageBaseDir + "marketplace-logo_hover.svg";
266+
std::string storeIconHoverPath =
267+
imageBaseDir + "marketplace-logo_hover.svg";
264268
QString buttonStyle = EIconHoverButtonStyle;
265269
buttonStyle.replace("${img}", storeIconPath.c_str());
266270
buttonStyle.replace("${hover-img}", storeIconHoverPath.c_str());
@@ -492,7 +496,6 @@ void ElgatoCloudWindow::initialize()
492496

493497
auto loadingWidget = new LoadingWidget(this); // Loading widget, id: 3
494498
_stackedContent->addWidget(loadingWidget);
495-
496499
//_config = new ElgatoCloudConfig(this);
497500
//_config->setVisible(false);
498501
connect(_config, &ElgatoCloudConfig::closeClicked, this, [this]() {
@@ -509,6 +512,11 @@ void ElgatoCloudWindow::initialize()
509512
setLayout(_layout);
510513
}
511514

515+
void ElgatoCloudWindow::setLoading()
516+
{
517+
_stackedContent->setCurrentIndex(3);
518+
}
519+
512520
void ElgatoCloudWindow::on_logInButton_clicked()
513521
{
514522
elgatoCloud->StartLogin();
@@ -536,6 +544,7 @@ void ElgatoCloudWindow::setLoggedIn()
536544
void ElgatoCloudWindow::setupOwnedProducts()
537545
{
538546
_ownedProducts->refreshProducts();
547+
_stackedContent->setCurrentIndex(0);
539548
}
540549

541550
ElgatoProductItem::ElgatoProductItem(QWidget *parent, ElgatoProduct *product)
@@ -743,7 +752,7 @@ LoadingWidget::LoadingWidget(QWidget *parent) : QWidget(parent)
743752
QSizePolicy::Expanding);
744753

745754
auto loading = new QLabel(this);
746-
loading->setText("Loading all of the things");
755+
loading->setText("Loading Your Purchased Products...");
747756
loading->setStyleSheet("QLabel {font-size: 18pt;}");
748757
loading->setAlignment(Qt::AlignCenter);
749758

@@ -772,6 +781,9 @@ void OpenElgatoCloudWindow()
772781

773782
ElgatoCloudWindow::window = new ElgatoCloudWindow(mainWindow);
774783
ElgatoCloudWindow::window->setAttribute(Qt::WA_DeleteOnClose);
784+
if (elgatoCloud->loggedIn) {
785+
ElgatoCloudWindow::window->setLoading();
786+
}
775787
ElgatoCloudWindow::window->show();
776788
ElgatoCloudWindow::window->move(
777789
hostRect.center() -
@@ -793,7 +805,7 @@ void CloseElgatoCloudWindow()
793805

794806
extern void InitElgatoCloud(obs_module_t *module)
795807
{
796-
obs_log(LOG_INFO, "version: %s", "0.0.1");
808+
obs_log(LOG_INFO, "version: %s", "0.0.2");
797809

798810
elgatoCloud = new ElgatoCloud(module);
799811
QAction *action = (QAction *)obs_frontend_add_tools_menu_qaction(

src/elgato-cloud-window.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class ElgatoCloudWindow : public QDialog {
203203

204204
void initialize();
205205
void setLoggedIn();
206+
void setLoading();
206207
void setupOwnedProducts();
207208

208209
static ElgatoCloudWindow *window;

src/export-wizard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace elgatocloud {
1414

15-
SceneBundle* bundle = new SceneBundle();
15+
SceneBundle *bundle = new SceneBundle();
1616

1717
SceneBundleStatus createBundle(std::string filename,
1818
std::vector<std::string> plugins,
@@ -36,7 +36,7 @@ const std::vector<std::string> ExcludedModules{
3636
"frontend-tools.dll", "decklink-output-ui.dll", "decklink-captions.dll",
3737
"coreaudio-encoder.dll",
3838
// This plugin
39-
"elgato-deeplinking.dll"};
39+
"elgato-marketplace.dll"};
4040

4141
FileCollectionCheck::FileCollectionCheck(QWidget *parent,
4242
std::vector<std::string> files)

src/plugin-support.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ with this program. If not, see <https://www.gnu.org/licenses/>
2020

2121
extern void blogva(int log_level, const char *format, va_list args);
2222

23-
const char *PLUGIN_NAME = "deeplinking";
24-
const char *PLUGIN_VERSION = "0.0.1";
23+
const char *PLUGIN_NAME = "elgato-marketplace";
24+
const char *PLUGIN_VERSION = "0.0.2";
2525

2626
void obs_log(int log_level, const char *format, ...)
2727
{

0 commit comments

Comments
 (0)