mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-03-23 19:44:13 +03:00
Merge pull request #6761 from javidcf/patch-1
Support arbitrary number of loaded modules on Windows
This commit is contained in:
commit
a22f6ddefa
|
@ -310,7 +310,7 @@ load_tkinter_funcs(void) {
|
||||||
* Return 0 for success, non-zero for failure.
|
* Return 0 for success, non-zero for failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
HMODULE hMods[1024];
|
HMODULE* hMods = NULL;
|
||||||
HANDLE hProcess;
|
HANDLE hProcess;
|
||||||
DWORD cbNeeded;
|
DWORD cbNeeded;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -327,33 +327,48 @@ load_tkinter_funcs(void) {
|
||||||
/* Returns pseudo-handle that does not need to be closed */
|
/* Returns pseudo-handle that does not need to be closed */
|
||||||
hProcess = GetCurrentProcess();
|
hProcess = GetCurrentProcess();
|
||||||
|
|
||||||
|
/* Allocate module handlers array */
|
||||||
|
if (!EnumProcessModules(hProcess, NULL, 0, &cbNeeded)) {
|
||||||
|
#if defined(__CYGWIN__)
|
||||||
|
PyErr_SetString(PyExc_OSError, "Call to EnumProcessModules failed");
|
||||||
|
#else
|
||||||
|
PyErr_SetFromWindowsErr(0);
|
||||||
|
#endif
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (!(hMods = (HMODULE*) malloc(cbNeeded))) {
|
||||||
|
PyErr_NoMemory();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Iterate through modules in this process looking for Tcl / Tk names */
|
/* Iterate through modules in this process looking for Tcl / Tk names */
|
||||||
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
|
if (EnumProcessModules(hProcess, hMods, cbNeeded, &cbNeeded)) {
|
||||||
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||||
if (!found_tcl) {
|
if (!found_tcl) {
|
||||||
found_tcl = get_tcl(hMods[i]);
|
found_tcl = get_tcl(hMods[i]);
|
||||||
if (found_tcl == -1) {
|
if (found_tcl == -1) {
|
||||||
return 1;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found_tk) {
|
if (!found_tk) {
|
||||||
found_tk = get_tk(hMods[i]);
|
found_tk = get_tk(hMods[i]);
|
||||||
if (found_tk == -1) {
|
if (found_tk == -1) {
|
||||||
return 1;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found_tcl && found_tk) {
|
if (found_tcl && found_tk) {
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(hMods);
|
||||||
if (found_tcl == 0) {
|
if (found_tcl == 0) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Could not find Tcl routines");
|
PyErr_SetString(PyExc_RuntimeError, "Could not find Tcl routines");
|
||||||
} else {
|
} else if (found_tk == 0) {
|
||||||
PyErr_SetString(PyExc_RuntimeError, "Could not find Tk routines");
|
PyErr_SetString(PyExc_RuntimeError, "Could not find Tk routines");
|
||||||
}
|
}
|
||||||
return 1;
|
return (int) ((found_tcl != 1) || (found_tk != 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* not Windows */
|
#else /* not Windows */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user