mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Get current directory from Windows launcher, preserve current directory for DLL loader (IDEA-218032)
GitOrigin-RevId: c92f4f93e397b21b4075a268eeec07062149cdbf
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f8b1322892
commit
32703e068a
@@ -579,6 +579,10 @@ bool LoadVMOptions()
|
||||
vmOptionLines.push_back(std::string("-Djava.library.path=") + binDirs);
|
||||
AddPredefinedVMOptions(vmOptionLines);
|
||||
|
||||
char curDir[_MAX_PATH];
|
||||
GetCurrentDirectoryA(_MAX_PATH - 1, curDir);
|
||||
vmOptionLines.push_back(std::string("-Dide.launcher.initialWorkingDir=\"") + curDir + "\"");
|
||||
|
||||
vmOptionCount = vmOptionLines.size() + 1;
|
||||
vmOptions = (JavaVMOption*)malloc(vmOptionCount * sizeof(JavaVMOption));
|
||||
|
||||
@@ -608,18 +612,14 @@ bool LoadJVMLibrary()
|
||||
dllName = clientDllName;
|
||||
}
|
||||
|
||||
// Call SetDllDirectory to allow jvm.dll to load the corresponding runtime libraries.
|
||||
SetDllDirectoryA(binDir.c_str());
|
||||
// Call SetCurrentDirectory to allow jvm.dll to load the corresponding runtime libraries.
|
||||
SetCurrentDirectoryA(binDir.c_str());
|
||||
hJVM = LoadLibraryA(dllName.c_str());
|
||||
if (hJVM)
|
||||
{
|
||||
pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM");
|
||||
}
|
||||
|
||||
// Now clean up the SetDllDirectory context, because otherwise it will pollute the child processes (and that is
|
||||
// often unwanted for any user programs started from IDE).
|
||||
SetDllDirectoryA(nullptr);
|
||||
|
||||
if (!pCreateJavaVM)
|
||||
{
|
||||
std::string jvmError = "Failed to load JVM DLL ";
|
||||
|
||||
@@ -351,7 +351,9 @@ open class IdeStarter : ApplicationStarter {
|
||||
var project: Project? = null
|
||||
if (commandLineArgs.firstOrNull() != null) {
|
||||
LOG.info("ApplicationLoader.loadProject")
|
||||
project = CommandLineProcessor.processExternalCommandLine(commandLineArgs, null).getFirst()
|
||||
val currentDirectory = System.getProperty("ide.launcher.initialWorkingDir")
|
||||
LOG.info("ide.launcher.initialWorkingDir: $currentDirectory")
|
||||
project = CommandLineProcessor.processExternalCommandLine(commandLineArgs, currentDirectory).getFirst()
|
||||
}
|
||||
return project
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user