Skip to content

Commit

Permalink
Merge pull request #3956 from daschuer/migrateOldSettings
Browse files Browse the repository at this point in the history
Make sure args.getSettingsPath() returns the correct directory
  • Loading branch information
uklotzde authored Jun 6, 2021
2 parents 17d14e9 + 5b1cbe8 commit a5bc82a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
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

0 comments on commit a5bc82a

Please sign in to comment.