summaryrefslogtreecommitdiff
path: root/native
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2014-02-06 14:02:54 -0800
committerTor Norbye <tnorbye@google.com>2014-02-06 14:02:59 -0800
commit70ae6f2a102f9dcd665861668cccae9590cdbef1 (patch)
treee5b3a4f2419b9f630851b209c02e14179b6fa2ba /native
parent809cb3e73653399e59e45e0b10749a8e37b85a75 (diff)
downloadidea-70ae6f2a102f9dcd665861668cccae9590cdbef1.tar.gz
Snapshot dc1944e804515a346297e368c3b9c35a203c9912 from idea/133.818 of git://git.jetbrains.org/idea/community.git
dc1944e: Merge remote-tracking branch 'origin/133' into 133 c2e9002: Merge remote-tracking branch 'origin/133' into 133 dbd4198: IDEA-117777 Change the way native splashscreen is shown in WinLauncher IDEA-117163 Parameter "nosplash" is broken on launcher (cherry picked from commit b783716) cfcbcbb: distinct prover: do not distinguish raw type arguments from type arguments without params (IDEA-119546) (cherry picked from commit baee0eb) a1b2686: Copyright: commit document after comment updating (cherry picked from commit 0f2e2a5) 210e309: IDEA-119677 AWT thread blocking during start up 607d561: do not replace checked exception with unchecked (IDEA-119345) 34d7d0d: cls reference ignores passed outer class type arguments (IDEA-118733) afb6d22: revert (IDEA-120153) 512ceae: temp solution (IDEA-118527) (cherry picked from commit 32094bf) a1cb63e: Merge remote-tracking branch 'origin/133' into 133 b90c09e: Logo updated: 'Tools matter' moved. 87174f2: [git] Don't read default commit message from .COMMIT_EDITMSG 00bc294: Add new plugins to brokenPlugins.txt a42d688: PyCharm 3.1 artwork c7a0fea: IDEA-119510 Update Pivotal connector to correctly set "Started" and "Finished" states for stories. Unify titles of error dialogs in "Close task" and "Open task" actions. (cherry picked from commit 85bcbe8) c498973: root detection call optimized for empty root checkers (cherry picked from commit acdc335) f54d2a5: unnecessary 'else' removed (cherry picked from commit 65bce6c) 2f60cdc: style (cherry picked from commit 321cebb) 0ca33de: VcsRootDetectorI renamed (cherry picked from commit 5a75778) e8a0a07: VcsRootDetector refactoring dd9ee0b: GitRootFinder removed as unnecessary (cherry picked from commit 470ad4d) 6061019: IDEA-119738 Problem with Android Studio connecting to wrong VCS (Git vs. Mercurial) a0afcc5: style (cherry picked from commit 1195dd4) 0b6023f: Mercurial Repository info problem fixed eae61e9: style (cherry picked from commit 96ec395) 6be71da: Unnecessary parameter --ignore removed from appropriate status commands. 8d896ca: Annotate for renamed/moved file fixed 95fe78f: getFileNameInTargetRevision updated 2eb0039: VcsRoot detector tests updated 5a89ec5: VcsRootError changed to be an interface, implementation moved to vcs-impl (cherry picked from commit 49815e2) 6e7297f: Reverted percent formatting by default for MySQL parser compatibility with Python (PY-10771) c92b0d9: Fixed add method quick fix after changing the element reported by the unresolved references inspection cede286: do not prefer simple python run configuration over tests fa2e308: do not prefer simple python run configuration over custom (django, etc.) 5bdf739: Don't use JSON to store broken plugins. Loading JSON on startup take 50m.s. e2617c0: Fill brokenPlugins.json (cherry picked from commit ebf4294) 50938aa: [git] IDEA-120042 Protect against zero timestamp 03b587d: Kill Python console with SIGKILL, because SIGINT generates KeyboardInterrupt and closes nothing. (cherry picked from commit 35603ff416a1c6b95d2ba4459fcc7bbb864315a1) 24baeea: NotNull annotation. (cherry picked from commit 8bf273fc402c574fe67f39f0a43018e0b3758cdd) 4fb7ecf: NotNull annotation. (cherry picked from commit 8204f64b865634da512600488441c5001e902c5d) 13a9206: NPE (EA-52843) (cherry picked from commit 5f2c78ef5b3b574d620aa3abe6a619c7deb143f5) 5bb5de4: EA-49160 (cherry picked from commit 2e82518e58e42959f9153f2685a1fb6c924b524e) d33f8a2: NPE(EA-52907). (cherry picked from commit b44000de9a05193e218d159565a40e10d0770afa) eb15fe6: IOOBE (EA-53138). (cherry picked from commit 1ac0a958e7902e9503b1584aa9a5099a5645592a) 5a76e10: SIOOBE(EA-53677). (cherry picked from commit 8e887d7) d0de4d4: Fixed spelling in names of variables (cherry picked from commit e37f9b1) 43d19a0: Simplified always true expressions (cherry picked from commit 61f5888) 0d1f896: Fixed EA-49990: assert: TextRange.<init> bf30c71: Fixed EA-52685 - assert: MultiHostRegistrarImpl.doneInjecting 845984e: Reordered methods (cherry picked from commit 35afccf) 4bd4b91: Fixed SQL 'select/insert/...' rule injection into indented string literals (PY-11970) (cherry picked from commit 5fd0a91) afc90e9: Assume that string without '%' operator or 'format()' contains no formatting (PY-11771) (cherry picked from commit 2621f17) 58b30ff: Don't run code analysis for injections with interpolation in string formatting (PY-11962) (cherry picked from commit 6e66b22) e7ff3f0: Add injection place even if a string fragment consists of zero chunks (cherry picked from commit e4bf6e4) 077db26: Fixed parsing of unbalanced new style string formatting (PY-11962) (cherry picked from commit 76e0d23) d1d3177: IDEA-56096 Allow to create file templates with extension contains dot [CR-IC-3923] (cherry picked from commit c1728ca) ef7c9e4: assume custom stubs only if psifile's content element type isn't IStubElementType, this fixes performance problem of previous change (that added support for dom indices). The performance problem was manifested for flex stubs produced by decompiler. (cherry picked from commit 4b5b6e8) 7ab32ff: IDEA-119773 (slf4j placeholder inspection false warnings when passing in Object array) (cherry picked from commit d8e1c94) f6951b4: high CPU and EditorTextField/LanguageConsole scrolling ef19cd4: [git] IDEA-119887 Support one more git version output format 6ebae26: [git] convert GitVersionTest to junit 86970d3: Add brokenPlugins.json 2f5b006: [^Peter] IDEA-117390 don't complete light elements containing IntelliJIdeaRulezzz 3abd741: [^peter]IDEA-119647 CCE on groovy file 585208a: Merge remote-tracking branch 'origin/133' into 133 6257aa0: PyCharm 3.1 a7af6ae: Gradle: buildscript configuration respect inheritance (cherry picked from commit 0f133cf) d2311e1: [github] IDEA-119693 Don't share workspace.xml 8ed66a5: EA-53411 (more reliable diagnostic and better recovery) 7ac7972: IDEA-119498 (only suppress plugin updates for true command-line usage) db1690c: IDEA-55171 (prevent sync refresh from locking if application is disposed) f9286bb: fixed merge problem: extra test method was added 5b068d0: Traverse class owners via ScopeUtil in order to prevent switching from stubs to AST 527b224: Compare decorators by name preventing unnecessary switch from stubs to AST d4d3308: Fix CCE (PY-10999). 8e0523a: Setup __loader__ for __main__ module (PY-10535). 273934b: Added test for PY-11337 989d3a3: PY-3569 Inspection to warn if a loop variable is assigned inside the loop 44efd68: fixed EA-53497 - assert: TextRange.<init> 85c7dee: better fix for IDEA-111684 (cherry picked from commit bb558e8) 50207de: 13.0.3 EAP e3dcc49: IDEA-103743 Settings > Code Style > Arrangement UI glitch (after-review improvement) (cherry picked from commit 4269a85) f6d1bd3: 1) IDEA-103743 Settings > Code Style > Arrangement UI glitch 2) checkbox unselection doesn't disable combobox (cherry picked from commit b788397) e145138: Do not allow view to be larger than viewport with SCROLLBAR_NEVER policy 5ea4a3b: IDEA-118601 New Module: Maven: click on "Create from archetype" reverts typed coordinates. (cherry picked from commit 34d1109) +review CR-IC-3798 83fe636: hotfix: IDEA-119851 Gradle: the "out-of-process" mode doesn't work 0d06fcd: Merge branch '133' of git.labs.intellij.net:idea/community into 133 c1c74dc: Revert "updated external tools. Added annoying *.whl for the needs of virtualenv." 5e91a0d: advance bomb 37c6d1b: add read action (EA-51111) 239497a: read action 9f91062: PY-11882 Assignment to for loop inspection false positive PY-3569 Inspection to warn if a loop variable is assigned inside the loop c571c78: Don't analyze target expressions not located in the current file 59eff48: PY-6955 Unused import not greyed out if also failing 2db3187: PY-6955 Unused import not greyed out if also failing db42545: PY-6955 Unused import not greyed out if also failing (test refactored) 7aa1822: PY-3569 Inspection to warn if a loop variable is assigned inside the loop 086e91e: PY-3569 Inspection to warn if a loop variable is assigned inside the loop a4d9d17: updated external tools. Added annoying *.whl for the needs of virtualenv. e03288e: Cache presence or absence of a user skeleton for file in its user data 0f403e5: Rewritten PyQualifiedReference.collectAssignedAttributes() for better performance cff2993: Cache the result of asQualifiedName() 938b089: Forgot call to super 5c00d1f: fixed missing sys import 7a48578: Disabled comment injector for Python for performance reasons 6e1a348: fixed missing sys import ecc919e: fixed PY-11561 "Add super class call" incorrectly inserts parameter annotations 30556f2: fixed PY-11495 Create function: do not propose quick-fix for unresolved parts of fqn 3697485: fixed PY-11484 Implement abstract method: pushes docstring out of the way 5fa3f46: fixed isAbstractmethod 40ad42e: Fix align multiline elements in parenthesized expressions, parameters and arguments lists. 269d729: Cleanup of API for qualified names of expressions 51fb114: Method call in indenting statement should have continuation indent. a29830e: fixed PY-11353 Creating Run Configuration from specific test gets the "target" wrong 4cbbccb: fixed PY-11312 False positive CamelCase variable imported as lowercase 72ace3a: fixed PY-11281 Convert dict comprehension to dict call omits if expression 145c46c: Deprecated PyResolveUtil.treeCrawlUp() as a slow way of traversing the PSI 04eb283: Made several internal methods of PyResolveUtil private ffe45f7: fixed PY-11277 Python: Wrong "argument equals default" inspection 819364e: fixed PY-11617 Nosetest runner: simple function tests cannot jump to source 9b389fc: fixed PY-11696 Cancel after adding new interpreter removes configured project interpreter a74d7e3: proper fix for PY-11879 23a7505: Added PyQualifiedReference.isQualified() that potentially doesn't require AST access 5991dac: Use ScopeUtil.getScopeOwner() for preventing unnecessary stubs to AST switch 04a4e01: fixed PY-11340 Invalid case for can't assign to literal inspection 0f03c21: fixed PY-11341 Invalid case for identifier expected inspection after as in with statement 90143fb: Fix continuation indentation in while statement (PY-11869). bba7892: default test runner is unittest 92d2caf: Cache the results of asQualifiedName() for performance reasons 7a9fffc: Indent comment in tuple (PY-11904). 5c7ac44: Fixed test data to satisfy PEP8. 1d845d9: fixed PY-11879 Refactor: Rename: references in ivar directive are not updated 50bcfc0: fixed PY-11884 Missing completion for finally keyword after else statement f2a14b8: Insert two spaces before line comment (PY-11901). 17e208c: Fix indent in parenthesized expression in indenting statement (PY-11868). 04c1a4a: Inject SQL only into strings that have SELECT/UPDATE... at the beginning 40ddc62: fixed PY-11428 "Variable in function should be lowercase" false positive for variables declared global e214615: Try stub-based containers for Python PSI elements instead of getParent() b7f8286: Use hasDefaultValue() instead of getDefaultValue() in order to prevent switching from stubs to AST 4831476: Qualified targets are never local 68e8c17: Use isQualified() instead of getQualifier() in order to prevent switching from stubs to AST d351953: Find owner via ScopeUtil in order to prevent switching from stubs to AST 28b4b21: Note about stubs to AST 65a8a45: Traverse class owners via ScopeUtil in order to prevent switching from stubs to AST 51aef87: Compare decorators by name preventing unnecessary switch from stubs to AST df0f3bb: Fixed NPE 9da12c1: Calculate iteration type via types, not PyClass elements ae275ce: fixed PY-11875 Pycharm code analysis stalls on specific code (caused by AIOOB in getArguments of decorator) a38300c: Removed redundant PyTypeProvider.getIterationType() 8e05ff9: Types of Enum members' fields and type of Enum.__members__ 94cb03f: Fixed PyABCUtil.isSubtype() check for class definitions that have metaclasses 0060111: Type provider for enum.Enum members cbb65bb: Store metaclass qualified name in class stub for better performance 79b43ed: Added PyClass.getMetaClassExpression() 7916719: Extracted getMetaClassExpression() 44a5f41: Evaluate metaclass type using TypeEvalContext 55fdf8e: Check __metaclass__ attribute only for Python 2.x 7afe4fc: Refactored PyUtil.getMetaClass() into PyClass.getMetaClassType() 14f98ae: Keywords already contains 'as' and 'with' c38e6a3: Merge PyKeywords with PyNames c4a0746: Extracted PyStdlibTypeProvider.getNamedTupleType() Change-Id: Ia6001b030336ec63b47f7b49d53a595cc7fc0598
Diffstat (limited to 'native')
-rw-r--r--native/WinLauncher/WinLauncher/WinLauncher.cpp199
1 files changed, 116 insertions, 83 deletions
diff --git a/native/WinLauncher/WinLauncher/WinLauncher.cpp b/native/WinLauncher/WinLauncher/WinLauncher.cpp
index 8d5ff13a46ed..a934a88da3d0 100644
--- a/native/WinLauncher/WinLauncher/WinLauncher.cpp
+++ b/native/WinLauncher/WinLauncher/WinLauncher.cpp
@@ -17,7 +17,7 @@
#include "stdafx.h"
#include "WinLauncher.h"
-typedef JNIIMPORT jint (JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args);
+typedef JNIIMPORT jint(JNICALL *JNI_createJavaVM)(JavaVM **pvm, JNIEnv **env, void *args);
HINSTANCE hInst; // current instance
char jvmPath[_MAX_PATH];
@@ -45,7 +45,7 @@ std::string LoadStdString(int id)
{
wchar_t *buf = NULL;
int len = LoadStringW(hInst, id, reinterpret_cast<LPWSTR>(&buf), 0);
- if (len)
+ if (len)
{
int cbANSI = WideCharToMultiByte(CP_ACP, 0, buf, len, NULL, 0, NULL, NULL);
char* ansiBuf = new char[cbANSI];
@@ -65,7 +65,7 @@ bool FileExists(const std::string& path)
bool IsValidJRE(const char* path)
{
std::string dllPath(path);
- if (dllPath[dllPath.size()-1] != '\\')
+ if (dllPath[dllPath.size() - 1] != '\\')
{
dllPath += "\\";
}
@@ -83,16 +83,16 @@ bool FindValidJVM(const char* path)
{
if (IsValidJRE(path))
{
- strcpy_s(jvmPath, _MAX_PATH-1, path);
+ strcpy_s(jvmPath, _MAX_PATH - 1, path);
return true;
}
char jrePath[_MAX_PATH];
strcpy_s(jrePath, path);
- if (jrePath[strlen(jrePath)-1] != '\\')
+ if (jrePath[strlen(jrePath) - 1] != '\\')
{
strcat_s(jrePath, "\\");
}
- strcat_s(jrePath, _MAX_PATH-1, "jre");
+ strcat_s(jrePath, _MAX_PATH - 1, "jre");
if (IsValidJRE(jrePath))
{
strcpy_s(jvmPath, jrePath);
@@ -104,13 +104,13 @@ bool FindValidJVM(const char* path)
std::string GetAdjacentDir(const char* suffix)
{
char libDir[_MAX_PATH];
- GetModuleFileNameA(NULL, libDir, _MAX_PATH-1);
+ GetModuleFileNameA(NULL, libDir, _MAX_PATH - 1);
char* lastSlash = strrchr(libDir, '\\');
if (!lastSlash) return "";
*lastSlash = '\0';
lastSlash = strrchr(libDir, '\\');
if (!lastSlash) return "";
- strcpy(lastSlash+1, suffix);
+ strcpy(lastSlash + 1, suffix);
strcat_s(libDir, "\\");
return std::string(libDir);
}
@@ -118,7 +118,7 @@ std::string GetAdjacentDir(const char* suffix)
bool FindJVMInEnvVar(const char* envVarName, bool& result)
{
char envVarValue[_MAX_PATH];
- if (GetEnvironmentVariableA(envVarName, envVarValue, _MAX_PATH-1))
+ if (GetEnvironmentVariableA(envVarName, envVarValue, _MAX_PATH - 1))
{
if (FindValidJVM(envVarValue))
{
@@ -145,9 +145,9 @@ bool FindJVMInRegistryKey(const char* key, bool wow64_32)
if (wow64_32) flags |= KEY_WOW64_32KEY;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey) != ERROR_SUCCESS) return false;
char javaHome[_MAX_PATH];
- DWORD javaHomeSize = _MAX_PATH-1;
+ DWORD javaHomeSize = _MAX_PATH - 1;
bool success = false;
- if (RegQueryValueExA(hKey, "JavaHome", NULL, NULL, (LPBYTE) javaHome, &javaHomeSize) == ERROR_SUCCESS)
+ if (RegQueryValueExA(hKey, "JavaHome", NULL, NULL, (LPBYTE)javaHome, &javaHomeSize) == ERROR_SUCCESS)
{
success = FindValidJVM(javaHome);
}
@@ -157,7 +157,7 @@ bool FindJVMInRegistryKey(const char* key, bool wow64_32)
bool FindJVMInRegistryWithVersion(const char* version, bool wow64_32)
{
- const char* keyName = LoadStdString(IDS_JDK_ONLY) == std::string("true")
+ const char* keyName = LoadStdString(IDS_JDK_ONLY) == std::string("true")
? "Java Development Kit"
: "Java Runtime Environment";
@@ -217,7 +217,7 @@ void TrimLine(char* line)
{
*p-- = '\0';
}
- while(p >= line && (*p == ' ' || *p == '\t'))
+ while (p >= line && (*p == ' ' || *p == '\t'))
{
*p-- = '\0';
}
@@ -227,9 +227,9 @@ bool LoadVMOptionsFile(const TCHAR* path, std::vector<std::string>& vmOptionLine
{
FILE *f = _tfopen(path, _T("rt"));
if (!f) return false;
-
+
char line[_MAX_PATH];
- while(fgets(line, _MAX_PATH-1, f))
+ while (fgets(line, _MAX_PATH - 1, f))
{
TrimLine(line);
if (line[0] == '#') continue;
@@ -253,7 +253,7 @@ std::string FindToolsJar()
size_t lastSlash = toolsJarPath.rfind('\\');
if (lastSlash != std::string::npos)
{
- toolsJarPath = toolsJarPath.substr(0, lastSlash+1) + "lib\\tools.jar";
+ toolsJarPath = toolsJarPath.substr(0, lastSlash + 1) + "lib\\tools.jar";
if (FileExists(toolsJarPath))
{
return toolsJarPath;
@@ -272,7 +272,7 @@ std::string CollectLibJars(const std::string& jarList)
std::string result;
int pos = 0;
- while(pos < jarList.size())
+ while (pos < jarList.size())
{
int delimiterPos = jarList.find(';', pos);
if (delimiterPos == std::string::npos)
@@ -284,8 +284,8 @@ std::string CollectLibJars(const std::string& jarList)
result += ";";
}
result += libDir;
- result += jarList.substr(pos, delimiterPos-pos);
- pos = delimiterPos+1;
+ result += jarList.substr(pos, delimiterPos - pos);
+ pos = delimiterPos + 1;
}
return result;
}
@@ -324,17 +324,17 @@ bool AddClassPathOptions(std::vector<std::string>& vmOptionLines)
void AddPredefinedVMOptions(std::vector<std::string>& vmOptionLines)
{
std::string vmOptions = LoadStdString(IDS_VM_OPTIONS);
- while(vmOptions.size() > 0)
+ while (vmOptions.size() > 0)
{
int pos = vmOptions.find(' ');
if (pos == std::string::npos) pos = vmOptions.size();
vmOptionLines.push_back(vmOptions.substr(0, pos));
- while(pos < vmOptions.size() && vmOptions[pos] == ' ') pos++;
+ while (pos < vmOptions.size() && vmOptions[pos] == ' ') pos++;
vmOptions = vmOptions.substr(pos);
}
char ideaProperties[_MAX_PATH];
- if (GetEnvironmentVariableA("IDEA_PROPERTIES", ideaProperties, _MAX_PATH-1))
+ if (GetEnvironmentVariableA("IDEA_PROPERTIES", ideaProperties, _MAX_PATH - 1))
{
vmOptionLines.push_back(std::string("-Didea.properties.file=") + ideaProperties);
}
@@ -343,17 +343,17 @@ void AddPredefinedVMOptions(std::vector<std::string>& vmOptionLines)
bool LoadVMOptions()
{
TCHAR optionsFileName[_MAX_PATH];
- if (LoadString(hInst, IDS_VM_OPTIONS_PATH, optionsFileName, _MAX_PATH-1))
+ if (LoadString(hInst, IDS_VM_OPTIONS_PATH, optionsFileName, _MAX_PATH - 1))
{
TCHAR fullOptionsFileName[_MAX_PATH];
- ExpandEnvironmentStrings(optionsFileName, fullOptionsFileName, _MAX_PATH-1);
-
+ ExpandEnvironmentStrings(optionsFileName, fullOptionsFileName, _MAX_PATH - 1);
+
if (GetFileAttributes(fullOptionsFileName) == INVALID_FILE_ATTRIBUTES)
{
- GetModuleFileName(NULL, fullOptionsFileName, _MAX_PATH-1);
+ GetModuleFileName(NULL, fullOptionsFileName, _MAX_PATH - 1);
_tcscat_s(fullOptionsFileName, _T(".vmoptions"));
}
-
+
std::vector<std::string> vmOptionLines;
if (LoadVMOptionsFile(fullOptionsFileName, vmOptionLines))
{
@@ -361,8 +361,8 @@ bool LoadVMOptions()
AddPredefinedVMOptions(vmOptionLines);
vmOptionCount = vmOptionLines.size();
- vmOptions = (JavaVMOption*) malloc(vmOptionCount * sizeof(JavaVMOption));
- for(int i=0; i<vmOptionLines.size(); i++)
+ vmOptions = (JavaVMOption*)malloc(vmOptionCount * sizeof(JavaVMOption));
+ for (int i = 0; i < vmOptionLines.size(); i++)
{
vmOptions[i].optionString = _strdup(vmOptionLines[i].c_str());
vmOptions[i].extraInfo = 0;
@@ -394,7 +394,7 @@ bool LoadJVMLibrary()
hJVM = LoadLibraryA(dllName.c_str());
if (hJVM)
{
- pCreateJavaVM = (JNI_createJavaVM) GetProcAddress(hJVM, "JNI_CreateJavaVM");
+ pCreateJavaVM = (JNI_createJavaVM)GetProcAddress(hJVM, "JNI_CreateJavaVM");
}
if (!pCreateJavaVM)
{
@@ -416,7 +416,7 @@ bool CreateJVM()
int result = pCreateJavaVM(&jvm, &env, &initArgs);
- for(int i=0; i<vmOptionCount; i++)
+ for (int i = 0; i < vmOptionCount; i++)
{
free(vmOptions[i].optionString);
}
@@ -438,11 +438,11 @@ jobjectArray PrepareCommandLine()
int numArgs;
LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
jclass stringClass = env->FindClass("java/lang/String");
- jobjectArray args = env->NewObjectArray(numArgs-1, stringClass, NULL);
- for(int i=1; i<numArgs; i++)
+ jobjectArray args = env->NewObjectArray(numArgs - 1, stringClass, NULL);
+ for (int i = 1; i < numArgs; i++)
{
const wchar_t* arg = argv[i];
- env->SetObjectArrayElement(args, i-1, env->NewString((const jchar *) arg, wcslen(argv[i])));
+ env->SetObjectArrayElement(args, i - 1, env->NewString((const jchar *)arg, wcslen(argv[i])));
}
return args;
}
@@ -484,7 +484,7 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
attachArgs.version = JNI_VERSION_1_2;
attachArgs.name = "WinLauncher external command processing thread";
attachArgs.group = NULL;
- jvm->AttachCurrentThread((void**) &env, &attachArgs);
+ jvm->AttachCurrentThread((void**)&env, &attachArgs);
std::string processorClassName = LoadStdString(IDS_COMMAND_LINE_PROCESSOR_CLASS);
jclass processorClass = env->FindClass(processorClassName.c_str());
@@ -493,8 +493,8 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
jmethodID processMethodID = env->GetStaticMethodID(processorClass, "processWindowsLauncherCommandLine", "(Ljava/lang/String;Ljava/lang/String;)V");
if (processMethodID)
{
- jstring jCurDir = env->NewString((const jchar *) curDir.c_str(), curDir.size());
- jstring jArgs = env->NewString((const jchar *) args.c_str(), args.size());
+ jstring jCurDir = env->NewString((const jchar *)curDir.c_str(), curDir.size());
+ jstring jArgs = env->NewString((const jchar *)args.c_str(), args.size());
env->CallStaticVoidMethod(processorClass, processMethodID, jCurDir, jArgs);
jthrowable exc = env->ExceptionOccurred();
if (exc)
@@ -509,7 +509,7 @@ void CallCommandLineProcessor(const std::wstring& curDir, const std::wstring& ar
DWORD WINAPI SingleInstanceThread(LPVOID args)
{
- while(true)
+ while (true)
{
WaitForSingleObject(hEvent, INFINITE);
if (terminating) break;
@@ -521,7 +521,7 @@ DWORD WINAPI SingleInstanceThread(LPVOID args)
if (pos >= 0)
{
std::wstring curDir = command.substr(0, pos);
- std::wstring args = command.substr(pos+1);
+ std::wstring args = command.substr(pos + 1);
CallCommandLineProcessor(curDir, args);
}
@@ -534,7 +534,7 @@ DWORD WINAPI SingleInstanceThread(LPVOID args)
void SendCommandLineToFirstInstance()
{
wchar_t curDir[_MAX_PATH];
- GetCurrentDirectoryW(_MAX_PATH-1, curDir);
+ GetCurrentDirectoryW(_MAX_PATH - 1, curDir);
std::wstring command(curDir);
command += _T("\n");
command += GetCommandLineW();
@@ -542,17 +542,17 @@ void SendCommandLineToFirstInstance()
void *view = MapViewOfFile(hFileMapping, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (view)
{
- memcpy(view, command.c_str(), (command.size()+1) * sizeof(wchar_t));
+ memcpy(view, command.c_str(), (command.size() + 1) * sizeof(wchar_t));
UnmapViewOfFile(view);
}
- SetEvent(hEvent);
+ SetEvent(hEvent);
}
bool CheckSingleInstance()
{
char moduleFileName[_MAX_PATH];
- GetModuleFileNameA(NULL, moduleFileName, _MAX_PATH-1);
- for(char *p = moduleFileName; *p; p++)
+ GetModuleFileNameA(NULL, moduleFileName, _MAX_PATH - 1);
+ for (char *p = moduleFileName; *p; p++)
{
if (*p == ':' || *p == '\\') *p = '_';
}
@@ -564,7 +564,7 @@ bool CheckSingleInstance()
hFileMapping = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, mappingName.c_str());
if (!hFileMapping)
{
- hFileMapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, FILE_MAPPING_SIZE,
+ hFileMapping = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, FILE_MAPPING_SIZE,
mappingName.c_str());
return true;
}
@@ -579,11 +579,11 @@ bool CheckSingleInstance()
void DrawSplashImage(HWND hWnd)
{
- HBITMAP hSplashBitmap = (HBITMAP) GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ HBITMAP hSplashBitmap = (HBITMAP)GetWindowLongPtr(hWnd, GWLP_USERDATA);
PAINTSTRUCT ps;
HDC hDC = BeginPaint(hWnd, &ps);
HDC hMemDC = CreateCompatibleDC(hDC);
- HBITMAP hOldBmp = (HBITMAP) SelectObject(hMemDC, hSplashBitmap);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(hMemDC, hSplashBitmap);
BITMAP splashBitmap;
GetObject(hSplashBitmap, sizeof(splashBitmap), &splashBitmap);
BitBlt(hDC, 0, 0, splashBitmap.bmWidth, splashBitmap.bmHeight, hMemDC, 0, 0, SRCCOPY);
@@ -594,12 +594,12 @@ void DrawSplashImage(HWND hWnd)
LRESULT CALLBACK SplashScreenWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
+ switch (uMsg)
{
case WM_PAINT:
DrawSplashImage(hWnd);
break;
- }
+ }
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@@ -616,7 +616,7 @@ void RegisterSplashScreenWndClass()
wcx.hInstance = hInst;
wcx.hIcon = 0;
wcx.hCursor = LoadCursor(NULL, IDC_WAIT);
- wcx.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
+ wcx.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcx.lpszMenuName = 0;
wcx.lpszClassName = splashClassName;
wcx.hIconSm = 0;
@@ -632,86 +632,120 @@ HWND ShowSplashScreenWindow(HBITMAP hSplashBitmap)
GetObject(hSplashBitmap, sizeof(splashBitmap), &splashBitmap);
int x = workArea.left + ((workArea.right - workArea.left) - splashBitmap.bmWidth) / 2;
int y = workArea.top + ((workArea.bottom - workArea.top) - splashBitmap.bmHeight) / 2;
-
+
HWND splashWindow = CreateWindowEx(WS_EX_TOOLWINDOW, splashClassName, splashClassName, WS_POPUP,
x, y, splashBitmap.bmWidth, splashBitmap.bmHeight, NULL, NULL, NULL, NULL);
- SetWindowLongPtr(splashWindow, GWLP_USERDATA, (LONG_PTR) hSplashBitmap);
+ SetWindowLongPtr(splashWindow, GWLP_USERDATA, (LONG_PTR)hSplashBitmap);
ShowWindow(splashWindow, SW_SHOW);
UpdateWindow(splashWindow);
return splashWindow;
}
+DWORD parentProcId;
+HANDLE parentProcHandle;
+
+BOOL IsParentProcessRunning(HANDLE hProcess)
+{
+ if (hProcess == NULL) return FALSE;
+ DWORD ret = WaitForSingleObject(hProcess, 0);
+ return ret == WAIT_TIMEOUT;
+}
+
BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
{
- static DWORD currentProcId = GetCurrentProcessId();
DWORD procId = 0;
GetWindowThreadProcessId(hWnd, &procId);
- if(currentProcId == procId)
+ if (parentProcId == procId)
{
- TCHAR className[_MAX_PATH];
- GetClassName(hWnd, className, _MAX_PATH-1);
- if (_tcscmp(className, splashClassName) != 0)
+ WINDOWINFO wi;
+ wi.cbSize = sizeof(WINDOWINFO);
+ GetWindowInfo(hWnd, &wi);
+ if ((wi.dwStyle & WS_VISIBLE) != 0)
{
- WINDOWINFO wi;
- wi.cbSize = sizeof(WINDOWINFO);
- GetWindowInfo(hWnd, &wi);
- if((wi.dwStyle & WS_VISIBLE) != 0)
- {
- HWND *phNewWindow = (HWND *) lParam;
- *phNewWindow = hWnd;
- return FALSE;
- }
+ HWND *phNewWindow = (HWND *)lParam;
+ *phNewWindow = hWnd;
+ return FALSE;
}
}
return TRUE;
}
-
-DWORD WINAPI SplashScreenThread(LPVOID args)
+DWORD WINAPI SplashScreen(HBITMAP hSplashBitmap)
{
- HBITMAP hSplashBitmap = static_cast<HBITMAP>(args);
RegisterSplashScreenWndClass();
HWND splashWindow = ShowSplashScreenWindow(hSplashBitmap);
-
MSG msg;
- while(true)
+ while (true)
{
- while (PeekMessage(&msg, splashWindow, 0, 0, PM_REMOVE))
+ while (PeekMessage(&msg, splashWindow, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(50);
HWND hNewWindow = NULL;
- EnumWindows(EnumWindowsProc, (LPARAM) &hNewWindow);
+ EnumWindows(EnumWindowsProc, (LPARAM)&hNewWindow);
if (hNewWindow)
{
BringWindowToTop(hNewWindow);
+ Sleep(100);
DeleteObject(hSplashBitmap);
DestroyWindow(splashWindow);
+ break;
}
+ if (!IsParentProcessRunning(parentProcHandle)) break;
}
return 0;
}
+void StartSplashProcess()
+{
+ TCHAR ownPath[_MAX_PATH];
+ TCHAR params[_MAX_PATH];
+
+ PROCESS_INFORMATION splashProcessInformation;
+ STARTUPINFO startupInfo;
+ memset(&splashProcessInformation, 0, sizeof(splashProcessInformation));
+ memset(&startupInfo, 0, sizeof(startupInfo));
+ startupInfo.cb = sizeof(startupInfo);
+ startupInfo.dwFlags = STARTF_USESHOWWINDOW;
+ startupInfo.wShowWindow = SW_SHOW;
+
+ GetModuleFileName(NULL, ownPath, (sizeof(ownPath)));
+ _snwprintf(params, _MAX_PATH, _T("SPLASH %d"), GetCurrentProcessId());
+ if (CreateProcess(ownPath, params, NULL, NULL, FALSE, 0, NULL, NULL, &startupInfo, &splashProcessInformation))
+ {
+ CloseHandle(splashProcessInformation.hProcess);
+ CloseHandle(splashProcessInformation.hThread);
+ }
+}
+
int APIENTRY _tWinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine,
- int nCmdShow)
+ HINSTANCE hPrevInstance,
+ LPTSTR lpCmdLine,
+ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
hInst = hInstance;
- if (!CheckSingleInstance()) return 1;
-
- HANDLE hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0));
- if (hSplashBitmap)
+ if (__argc == 2 && _wcsicmp(__wargv[0], _T("SPLASH")) == 0)
{
- CreateThread(NULL, 0, SplashScreenThread, hSplashBitmap, 0, NULL);
+ HBITMAP hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0));
+ if (hSplashBitmap)
+ {
+ parentProcId = _wtoi(__wargv[1]);
+ parentProcHandle = OpenProcess(SYNCHRONIZE, FALSE, parentProcId);
+ if (IsParentProcessRunning(parentProcHandle)) SplashScreen(hSplashBitmap);
+ }
+ CloseHandle(parentProcHandle);
+ return 0;
}
+ if (!CheckSingleInstance()) return 1;
+
+ if (wcsstr(lpCmdLine, _T("nosplash")) == NULL) StartSplashProcess();
+
if (!LocateJVM()) return 1;
if (!LoadVMOptions()) return 1;
if (!LoadJVMLibrary()) return 1;
@@ -731,4 +765,3 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
return 0;
}
- \ No newline at end of file