2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Have a global Core::Launcher accessor

This allows to use Launcher in code executing before Sandbox is created
This commit is contained in:
Ilya Fedin
2023-06-13 04:34:27 +04:00
committed by John Preston
parent 63ccf1bed4
commit a7bd097b2f
13 changed files with 50 additions and 70 deletions

View File

@@ -24,8 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Platform {
namespace {
Launcher *LauncherInstance = nullptr;
class Arguments {
public:
void push(QByteArray argument) {
@@ -50,15 +48,6 @@ private:
Launcher::Launcher(int argc, char *argv[])
: Core::Launcher(argc, argv)
, _arguments(argv, argv + argc) {
Expects(LauncherInstance == nullptr);
LauncherInstance = this;
}
Launcher &Launcher::Instance() {
Expects(LauncherInstance != nullptr);
return *LauncherInstance;
}
int Launcher::exec() {

View File

@@ -15,8 +15,6 @@ class Launcher : public Core::Launcher {
public:
Launcher(int argc, char *argv[]);
static Launcher &Instance();
int exec() override;
private:

View File

@@ -15,10 +15,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/platform/linux/base_linux_xdp_utilities.h"
#include "platform/linux/linux_desktop_environment.h"
#include "platform/linux/linux_wayland_integration.h"
#include "platform/platform_launcher.h"
#include "lang/lang_keys.h"
#include "mainwindow.h"
#include "storage/localstorage.h"
#include "core/launcher.h"
#include "core/sandbox.h"
#include "core/application.h"
#include "core/local_url_handlers.h"
@@ -138,7 +138,7 @@ bool PortalAutostart(bool start, bool silent) {
std::vector<Glib::ustring> commandline;
commandline.push_back(cExeName().toStdString());
if (Core::Sandbox::Instance().customWorkingDir()) {
if (Core::Launcher::Instance().customWorkingDir()) {
commandline.push_back("-workdir");
commandline.push_back(cWorkingDir().toStdString());
}
@@ -403,7 +403,7 @@ bool GenerateDesktopFile(
exec.append(!Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName());
if (Core::Sandbox::Instance().customWorkingDir()) {
if (Core::Launcher::Instance().customWorkingDir()) {
exec.append(u"-workdir"_q);
exec.append(cWorkingDir());
}
@@ -426,7 +426,7 @@ bool GenerateDesktopFile(
exec[0] = !Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName();
if (Core::Sandbox::Instance().customWorkingDir()) {
if (Core::Launcher::Instance().customWorkingDir()) {
exec.insert(1, u"-workdir"_q);
exec.insert(2, cWorkingDir());
}
@@ -479,7 +479,7 @@ bool GenerateDesktopFile(
const auto d = QFile::encodeName(QDir(cWorkingDir()).absolutePath());
hashMd5Hex(d.constData(), d.size(), md5Hash);
if (!Core::Sandbox::Instance().customWorkingDir()) {
if (!Core::Launcher::Instance().customWorkingDir()) {
const auto exePath = QFile::encodeName(
cExeDir() + cExeName());
hashMd5Hex(exePath.constData(), exePath.size(), md5Hash);
@@ -676,7 +676,7 @@ void start() {
if (!Core::UpdaterDisabled()) {
QByteArray md5Hash(h);
if (!Launcher::Instance().customWorkingDir()) {
if (!Core::Launcher::Instance().customWorkingDir()) {
const auto exePath = QFile::encodeName(
cExeDir() + cExeName());
@@ -726,6 +726,8 @@ void start() {
h,
cGUIDStr(),
u"%1"_q).toStdString());
InstallLauncher();
}
void finish() {
@@ -805,7 +807,6 @@ void start() {
"except various functionality to not to work.");
}
InstallLauncher();
LaunchGApplication();
}