Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure args.getSettingsPath() returns the correct directory #3956

Merged
merged 1 commit into from
Jun 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ int main(int argc, char * argv[]) {
// the main thread. Bug #1748636.
ErrorDialogHandler::instance();

MixxxApplication app(argc, argv);
#ifdef __APPLE__
Sandbox::checkSandboxed();
if (!args.getSettingsPathSet()) {
args.setSettingsPath(Sandbox::migrateOldSettings());
}
#endif

MixxxApplication app(argc, argv);

#ifdef __APPLE__
QDir dir(QApplication::applicationDirPath());
Expand Down
6 changes: 0 additions & 6 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args)
mixxx::Time::start();

QString settingsPath = args.getSettingsPath();
#ifdef __APPLE__
Sandbox::checkSandboxed();
if (!args.getSettingsPathSet()) {
settingsPath = Sandbox::migrateOldSettings();
}
#endif

mixxx::LogFlags logFlags = mixxx::LogFlag::LogToFile;
if (args.getDebugAssertBreak()) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/cmdlineargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ bool CmdlineArgs::Parse(int &argc, char **argv) {
if (!m_settingsPath.endsWith("/")) {
m_settingsPath.append("/");
}
m_settingsPathSet=true;
m_settingsPathSet = true;
} else if (argv[i] == QString("--resourcePath") && i+1 < argc) {
m_resourcePath = QString::fromLocal8Bit(argv[i+1]);
i++;
Expand Down
4 changes: 2 additions & 2 deletions src/util/sandbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ SecurityTokenPointer Sandbox::openTokenFromBookmark(const QString& canonicalPath
return SecurityTokenPointer();
}

#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 @@ -438,7 +439,6 @@ QString Sandbox::migrateOldSettings() {
return sandboxedPath;
}

#ifdef __APPLE__
CFURLRef url = CFURLCreateWithFileSystemPath(
kCFAllocatorDefault, QStringToCFString(legacySettingsPath), kCFURLPOSIXPathStyle, true);
if (url) {
Expand Down Expand Up @@ -498,9 +498,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 @@ -32,7 +32,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