Files
obs-studio/UI/update/mac-update.cpp
PatTheMav 710d99ef4d UI: Improve incremental compile times via explicit file includes
When a source file contains an explicit include with a filename
following the "moc_<actual-filename>.cpp" pattern, then CMake's
AUTOMOC generation tool will recognize the matching pair and generate
the replacement header file and add the required include directory
entries.

For all files which do contain Q_OBJECT or similar declarations but do
not have an explicit include directive, the global mocs_compilation.cpp
file will still be generated (which groups all "missing" generated
headers).

The larger this global file is, the more expensive incremental
compilation will be as this file (and all its contained generated
headers) will be re-generated regardless of whether actual changes
occurred.
2024-08-22 16:45:12 -04:00

84 lines
2.3 KiB
C++

#include "update-helpers.hpp"
#include "shared-update.hpp"
#include "moc_mac-update.cpp"
#include "obs-app.hpp"
#include <string>
#include <qt-wrappers.hpp>
#include <QMessageBox>
/* ------------------------------------------------------------------------ */
static const char *MAC_BRANCHES_URL =
"https://obsproject.com/update_studio/branches.json";
static const char *MAC_DEFAULT_BRANCH = "stable";
/* ------------------------------------------------------------------------ */
bool GetBranch(std::string &selectedBranch)
{
const char *config_branch =
config_get_string(GetGlobalConfig(), "General", "UpdateBranch");
if (!config_branch)
return true;
bool found = false;
for (const UpdateBranch &branch : App()->GetBranches()) {
if (branch.name != config_branch)
continue;
/* A branch that is found but disabled will just silently fall back to
* the default. But if the branch was removed entirely, the user should
* be warned, so leave this false *only* if the branch was removed. */
found = true;
if (branch.is_enabled) {
selectedBranch = branch.name.toStdString();
}
break;
}
return found;
}
/* ------------------------------------------------------------------------ */
void MacUpdateThread::infoMsg(const QString &title, const QString &text)
{
OBSMessageBox::information(App()->GetMainWindow(), title, text);
}
void MacUpdateThread::info(const QString &title, const QString &text)
{
QMetaObject::invokeMethod(this, "infoMsg", Qt::BlockingQueuedConnection,
Q_ARG(QString, title), Q_ARG(QString, text));
}
void MacUpdateThread::run()
try {
std::string text;
std::string branch = MAC_DEFAULT_BRANCH;
/* ----------------------------------- *
* get branches from server */
if (FetchAndVerifyFile("branches", "obs-studio/updates/branches.json",
MAC_BRANCHES_URL, &text))
App()->SetBranchData(text);
/* ----------------------------------- *
* Validate branch selection */
if (!GetBranch(branch)) {
config_set_string(GetGlobalConfig(), "General", "UpdateBranch",
MAC_DEFAULT_BRANCH);
info(QTStr("Updater.BranchNotFound.Title"),
QTStr("Updater.BranchNotFound.Text"));
}
emit Result(QString::fromStdString(branch), manualUpdate);
} catch (std::string &text) {
blog(LOG_WARNING, "%s: %s", __FUNCTION__, text.c_str());
}