mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
windows issues
This commit is contained in:
parent
201cdf2c86
commit
58555a2895
@ -303,6 +303,12 @@ class AppRunner(DirectObject):
|
|||||||
if mainName:
|
if mainName:
|
||||||
moduleName = mainName
|
moduleName = mainName
|
||||||
|
|
||||||
|
# Temporarily clear this flag while we import the app, so
|
||||||
|
# that if the app calls run() within its own main.py, it
|
||||||
|
# will properly get ignored by ShowBase.
|
||||||
|
interactiveConsole = self.interactiveConsole
|
||||||
|
self.interactiveConsole = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
__import__(moduleName)
|
__import__(moduleName)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -312,6 +318,9 @@ class AppRunner(DirectObject):
|
|||||||
if hasattr(main, 'main') and callable(main.main):
|
if hasattr(main, 'main') and callable(main.main):
|
||||||
main.main(self)
|
main.main(self)
|
||||||
|
|
||||||
|
# Now restore this flag.
|
||||||
|
self.interactiveConsole = interactiveConsole
|
||||||
|
|
||||||
if self.interactiveConsole:
|
if self.interactiveConsole:
|
||||||
# At this point, we have successfully loaded the app.
|
# At this point, we have successfully loaded the app.
|
||||||
# If the interactive_console flag is enabled, stop the
|
# If the interactive_console flag is enabled, stop the
|
||||||
|
@ -435,6 +435,9 @@ class Packager:
|
|||||||
# files). This will include the extension modules we just
|
# files). This will include the extension modules we just
|
||||||
# discovered above.
|
# discovered above.
|
||||||
for file in self.files:
|
for file in self.files:
|
||||||
|
if file.isExcluded(self):
|
||||||
|
# Skip this file.
|
||||||
|
continue
|
||||||
ext = Filename(file.newName).getExtension()
|
ext = Filename(file.newName).getExtension()
|
||||||
if file.unprocessed:
|
if file.unprocessed:
|
||||||
# Add an unprocessed file verbatim.
|
# Add an unprocessed file verbatim.
|
||||||
@ -466,6 +469,9 @@ class Packager:
|
|||||||
# We walk through the list as we modify it. That's OK,
|
# We walk through the list as we modify it. That's OK,
|
||||||
# because we may add new files that we want to process.
|
# because we may add new files that we want to process.
|
||||||
for file in self.files:
|
for file in self.files:
|
||||||
|
if file.isExcluded(self):
|
||||||
|
# Skip this file.
|
||||||
|
continue
|
||||||
ext = Filename(file.newName).getExtension()
|
ext = Filename(file.newName).getExtension()
|
||||||
if file.unprocessed:
|
if file.unprocessed:
|
||||||
# Already handled, above.
|
# Already handled, above.
|
||||||
|
@ -130,14 +130,32 @@ run_python() {
|
|||||||
|
|
||||||
// We'll need libpandaexpress to be imported before we can load
|
// We'll need libpandaexpress to be imported before we can load
|
||||||
// _vfsimporter. So, find it and load it.
|
// _vfsimporter. So, find it and load it.
|
||||||
Filename libpandaexpress(_archive_file.get_dirname(),
|
Filename libpandaexpress;
|
||||||
Filename::dso_filename("libpandaexpress.so"));
|
|
||||||
#if defined(__APPLE__) && PY_VERSION_HEX < 0x02050000
|
|
||||||
// On OSX, for Python versions 2.4 and before, we have to load the
|
|
||||||
// .so file, not the .dylib file.
|
|
||||||
libpandaexpress.set_type(Filename::T_general);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Of course it's already resident, so use that version.
|
||||||
|
HMODULE h = GetModuleHandle("libpandaexpress.dll");
|
||||||
|
if (h == NULL) {
|
||||||
|
nout << "Can't find libpandaexpress in memory.\n";
|
||||||
|
} else {
|
||||||
|
static const int buffer_size = 4096;
|
||||||
|
char buffer[buffer_size];
|
||||||
|
GetModuleFileName(h, buffer, buffer_size);
|
||||||
|
libpandaexpress = Filename::from_os_specific(buffer);
|
||||||
|
}
|
||||||
|
#endif // _WIN32
|
||||||
|
|
||||||
|
if (libpandaexpress.empty()) {
|
||||||
|
// Go look for it on disk.
|
||||||
|
libpandaexpress = Filename(_archive_file.get_dirname(),
|
||||||
|
Filename::dso_filename("libpandaexpress.so"));
|
||||||
|
#if defined(__APPLE__) && PY_VERSION_HEX < 0x02050000
|
||||||
|
// On OSX, for Python versions 2.4 and before, we have to load the
|
||||||
|
// .so file, not the .dylib file.
|
||||||
|
libpandaexpress.set_type(Filename::T_general);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!libpandaexpress.exists()) {
|
if (!libpandaexpress.exists()) {
|
||||||
nout << "Can't find " << libpandaexpress << "\n";
|
nout << "Can't find " << libpandaexpress << "\n";
|
||||||
return false;
|
return false;
|
||||||
@ -350,12 +368,19 @@ run_python() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void P3DPythonRun::
|
void P3DPythonRun::
|
||||||
run_interactive_console() {
|
run_interactive_console() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
// Make sure that control-C support is enabled for the interpreter.
|
||||||
|
SetConsoleCtrlHandler(NULL, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// The "readline" module makes the Python prompt friendlier, with
|
// The "readline" module makes the Python prompt friendlier, with
|
||||||
// command history and everything. Simply importing it is
|
// command history and everything. Simply importing it is
|
||||||
// sufficient.
|
// sufficient.
|
||||||
PyObject *readline_module = PyImport_ImportModule("readline");
|
PyObject *readline_module = PyImport_ImportModule("readline");
|
||||||
if (readline_module == NULL) {
|
if (readline_module == NULL) {
|
||||||
PyErr_Print();
|
// But, the module might not exist on certain platforms. If not,
|
||||||
|
// no sweat.
|
||||||
|
PyErr_Clear();
|
||||||
} else {
|
} else {
|
||||||
Py_DECREF(readline_module);
|
Py_DECREF(readline_module);
|
||||||
}
|
}
|
||||||
|
@ -148,11 +148,13 @@ run(int argc, char *argv[]) {
|
|||||||
token._value = "1";
|
token._value = "1";
|
||||||
_tokens.push_back(token);
|
_tokens.push_back(token);
|
||||||
|
|
||||||
#ifndef _WIN32
|
// We should also ignore control-C in this case, so that an
|
||||||
// We should also ignore SIGINT in this case, so that a
|
// interrupt will be delivered to the subordinate Python
|
||||||
// control-C operation will be delivered to the subordinate
|
// process and return to a command shell, and won't just kill
|
||||||
// Python process and return to a command shell, and won't
|
// the panda3d process.
|
||||||
// just kill the panda3d process.
|
#ifdef _WIN32
|
||||||
|
SetConsoleCtrlHandler(NULL, true);
|
||||||
|
#else
|
||||||
struct sigaction ignore;
|
struct sigaction ignore;
|
||||||
memset(&ignore, 0, sizeof(ignore));
|
memset(&ignore, 0, sizeof(ignore));
|
||||||
ignore.sa_handler = SIG_IGN;
|
ignore.sa_handler = SIG_IGN;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user