1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

macOS: always change working directory for launcher and server

This make relative paths work properly when launched from DMG or from different directory.
This commit is contained in:
Arseniy Shestakov 2017-08-09 01:09:29 +03:00
parent cb40c093f8
commit 21074e13c3
5 changed files with 14 additions and 4 deletions

View File

@ -229,7 +229,7 @@ int wmain(int argc, wchar_t* argv[])
#elif defined(VCMI_APPLE) || defined(VCMI_ANDROID)
int SDL_main(int argc, char *argv[])
#else
int main(int argc, char** argv)
int main(int argc, char * argv[])
#endif
{
#ifdef VCMI_ANDROID

View File

@ -12,7 +12,7 @@
#include "mainwindow_moc.h"
#include "sdldisplayquery.h"
int main(int argc, char *argv[])
int main(int argc, char * argv[])
{
QApplication vcmilauncher(argc, argv);
auto displayList = getDisplays();

View File

@ -21,6 +21,10 @@
void MainWindow::load()
{
// Set current working dir to executable folder.
// This is important on Mac for relative paths to work inside DMG.
QDir::setCurrent(QApplication::applicationDirPath());
console = new CConsoleHandler();
CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Launcher_log.txt", console);
logConfig.configureDefault();

View File

@ -607,8 +607,14 @@ void handleLinuxSignal(int sig)
}
#endif
int main(int argc, char** argv)
int main(int argc, char * argv[])
{
#ifdef VCMI_APPLE
// Correct working dir executable folder (not bundle folder) so we can use executable relative paths
std::string executablePath = argv[0];
std::string workDir = executablePath.substr(0, executablePath.rfind('/'));
chdir(workDir.c_str());
#endif
// Installs a sig sev segmentation violation handler
// to log stacktrace
#if defined(__GNUC__) && !defined (__MINGW32__) && !defined(VCMI_ANDROID)

View File

@ -12,7 +12,7 @@
#include "CVcmiTestConfig.h"
#include "../lib/filesystem/CMemoryBuffer.h"
int main(int argc, char ** argv)
int main(int argc, char * argv[])
{
::testing::InitGoogleTest(&argc, argv);
CVcmiTestConfig test;