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:
parent
cb40c093f8
commit
21074e13c3
@ -229,7 +229,7 @@ int wmain(int argc, wchar_t* argv[])
|
|||||||
#elif defined(VCMI_APPLE) || defined(VCMI_ANDROID)
|
#elif defined(VCMI_APPLE) || defined(VCMI_ANDROID)
|
||||||
int SDL_main(int argc, char *argv[])
|
int SDL_main(int argc, char *argv[])
|
||||||
#else
|
#else
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char * argv[])
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef VCMI_ANDROID
|
#ifdef VCMI_ANDROID
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "mainwindow_moc.h"
|
#include "mainwindow_moc.h"
|
||||||
#include "sdldisplayquery.h"
|
#include "sdldisplayquery.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
QApplication vcmilauncher(argc, argv);
|
QApplication vcmilauncher(argc, argv);
|
||||||
auto displayList = getDisplays();
|
auto displayList = getDisplays();
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
void MainWindow::load()
|
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();
|
console = new CConsoleHandler();
|
||||||
CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Launcher_log.txt", console);
|
CBasicLogConfigurator logConfig(VCMIDirs::get().userCachePath() / "VCMI_Launcher_log.txt", console);
|
||||||
logConfig.configureDefault();
|
logConfig.configureDefault();
|
||||||
|
@ -607,8 +607,14 @@ void handleLinuxSignal(int sig)
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
// Installs a sig sev segmentation violation handler
|
||||||
// to log stacktrace
|
// to log stacktrace
|
||||||
#if defined(__GNUC__) && !defined (__MINGW32__) && !defined(VCMI_ANDROID)
|
#if defined(__GNUC__) && !defined (__MINGW32__) && !defined(VCMI_ANDROID)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "CVcmiTestConfig.h"
|
#include "CVcmiTestConfig.h"
|
||||||
#include "../lib/filesystem/CMemoryBuffer.h"
|
#include "../lib/filesystem/CMemoryBuffer.h"
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
CVcmiTestConfig test;
|
CVcmiTestConfig test;
|
||||||
|
Loading…
Reference in New Issue
Block a user