Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/2.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Jun 7, 2021
2 parents a0d1c2d + a5bc82a commit c8f148e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
6 changes: 0 additions & 6 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ CoreServices::CoreServices(const CmdlineArgs& args)

void CoreServices::initializeSettings() {
QString settingsPath = m_cmdlineArgs.getSettingsPath();
#ifdef __APPLE__
Sandbox::checkSandboxed();
if (!m_cmdlineArgs.getSettingsPathSet()) {
settingsPath = Sandbox::migrateOldSettings();
}
#endif
m_pSettingsManager = std::make_unique<SettingsManager>(settingsPath);
}

Expand Down
19 changes: 13 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ int main(int argc, char * argv[]) {
QCoreApplication::setApplicationName(VersionStore::applicationName());
QCoreApplication::setApplicationVersion(VersionStore::version());

// Construct a list of strings based on the command line arguments
CmdlineArgs& args = CmdlineArgs::Instance();
if (!args.parse(argc, argv)) {
return kParseCmdlineArgsErrorExitCode;
}

// If you change this here, you also need to change it in
// ErrorDialogHandler::errorDialog(). TODO(XXX): Remove this hack.
QThread::currentThread()->setObjectName("Main");
Expand All @@ -81,13 +87,14 @@ int main(int argc, char * argv[]) {
// the main thread. Bug #1748636.
ErrorDialogHandler::instance();

MixxxApplication app(argc, argv);

// Construct a list of strings based on the command line arguments
CmdlineArgs& args = CmdlineArgs::Instance();
if (!args.parse(app.arguments())) {
return kParseCmdlineArgsErrorExitCode;
#ifdef __APPLE__
Sandbox::checkSandboxed();
if (!args.getSettingsPathSet()) {
args.setSettingsPath(Sandbox::migrateOldSettings());
}
#endif

MixxxApplication app(argc, argv);

#ifdef __APPLE__
QDir dir(QApplication::applicationDirPath());
Expand Down
8 changes: 1 addition & 7 deletions src/test/mixxxtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ QString makeTestConfigFile(const QString& path) {
QScopedPointer<MixxxApplication> MixxxTest::s_pApplication;

MixxxTest::ApplicationScope::ApplicationScope(int& argc, char** argv) {
// Construct a list of strings based on the command line arguments
CmdlineArgs args;
QStringList argList;
for (int i = 0; i < argc; i++) {
argList << QString::fromLocal8Bit(argv[i]);
}

const bool argsParsed = args.parse(argList);
const bool argsParsed = args.parse(argc, argv);
Q_UNUSED(argsParsed);
DEBUG_ASSERT(argsParsed);

Expand Down
13 changes: 10 additions & 3 deletions src/util/cmdlineargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ bool parseLogLevel(
}
} // namespace

bool CmdlineArgs::parse(const QStringList& arguments) {
bool CmdlineArgs::parse(int& argc, char** argv) {
QStringList arguments;
arguments.reserve(argc);
for (int a = 0; a < argc; ++a) {
arguments << QString::fromLocal8Bit(argv[a]);
}

QCommandLineParser parser;
parser.setApplicationDescription(QCoreApplication::translate("main",
"Mixxx is an open source DJ software. For more information, "
Expand Down Expand Up @@ -183,8 +189,9 @@ bool CmdlineArgs::parse(const QStringList& arguments) {
}

if (parser.isSet(helpOption) || parser.isSet(QStringLiteral("help-all"))) {
// we need to call process here otherwise there is no way to print the
// help-all information
// we need to call process here with an initialized QCoreApplication
// otherwise there is no way to print the help-all information
QCoreApplication coreApp(argc, argv);
parser.process(arguments);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/cmdlineargs.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CmdlineArgs final {
return cla;
}

bool parse(const QStringList& arguments);
bool parse(int& argc, char** argv);

const QList<QString>& getMusicFiles() const { return m_musicFiles; }
bool getStartInFullscreen() const { return m_startInFullscreen; }
Expand Down
4 changes: 2 additions & 2 deletions src/util/sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ SecurityTokenPointer Sandbox::openTokenFromBookmark(const QString& canonicalPath
return nullptr;
}

#ifdef __APPLE__
QString Sandbox::migrateOldSettings() {
// QStandardPaths::DataLocation returns a different location depending on whether the build
// is signed (and therefore sandboxed with the hardened runtime), so use the absolute path
Expand Down Expand Up @@ -469,7 +470,6 @@ QString Sandbox::migrateOldSettings() {
return sandboxedPath;
}

#ifdef __APPLE__
CFURLRef url = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, QStringToCFString(legacySettingsPath), kCFURLPOSIXPathStyle, true);
if (url) {
Expand Down Expand Up @@ -529,9 +529,9 @@ QString Sandbox::migrateOldSettings() {
}
}
}
#endif
return sandboxedPath;
}
#endif

#ifdef __APPLE__
SandboxSecurityToken::SandboxSecurityToken(const QString& path, CFURLRef url)
Expand Down
2 changes: 2 additions & 0 deletions src/util/sandbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class Sandbox {
static void setPermissionsFilePath(const QString& permissionsFile);
static void shutdown();

#ifdef __APPLE__
static QString migrateOldSettings();
#endif

// Returns true if we are in a sandbox.
static bool enabled() {
Expand Down

0 comments on commit c8f148e

Please sign in to comment.