more tweaks
This commit is contained in:
parent
095c719f9d
commit
66d4fca74b
|
|
@ -360,7 +360,8 @@ handle_pyobj_command(TiXmlElement *xcommand, bool needs_response,
|
|||
} else if (strcmp(method_name, "__repr__") == 0) {
|
||||
result = PyObject_Repr(obj);
|
||||
|
||||
} else if (strcmp(method_name, "__str__") == 0) {
|
||||
} else if (strcmp(method_name, "__str__") == 0 ||
|
||||
strcmp(method_name, "toString") == 0) {
|
||||
result = PyObject_Str(obj);
|
||||
|
||||
} else if (strcmp(method_name, "__setattr__") == 0) {
|
||||
|
|
|
|||
|
|
@ -260,13 +260,14 @@ command_and_response(TiXmlDocument *command) {
|
|||
|
||||
// Now block, waiting for a response to be delivered. We assume
|
||||
// only one thread will be waiting at a time.
|
||||
nout << "waiting for response " << response_id << "\n" << flush;
|
||||
_response_ready.acquire();
|
||||
while (_response == NULL || _got_response_id != response_id) {
|
||||
if (_response != NULL) {
|
||||
// This is a bogus response. Since we're the only thread waiting,
|
||||
// it follows that no one is waiting for this response, so we can
|
||||
// throw it away.
|
||||
nout << "Discarding bogus response: " << *_response << "\n";
|
||||
nout << "Discarding bogus response: " << *_response << "\n" << flush;
|
||||
delete _response;
|
||||
_response = NULL;
|
||||
_got_response_id = -1;
|
||||
|
|
@ -294,6 +295,7 @@ command_and_response(TiXmlDocument *command) {
|
|||
// We wait with a timeout, so we can go back and spin the event
|
||||
// loop some more.
|
||||
_response_ready.wait(0.1);
|
||||
nout << "." << flush;
|
||||
#else // _WIN32
|
||||
|
||||
// On non-Windows platforms, we can just wait indefinitely.
|
||||
|
|
@ -301,6 +303,7 @@ command_and_response(TiXmlDocument *command) {
|
|||
#endif // _WIN32
|
||||
}
|
||||
// When we exit the loop, we've found the desired response.
|
||||
nout << "got response: " << *_response << "\n" << flush;
|
||||
|
||||
TiXmlDocument *response = _response;
|
||||
_response = NULL;
|
||||
|
|
|
|||
|
|
@ -139,6 +139,10 @@ set_window(NPWindow *window) {
|
|||
// trick to allow us to poll events in the main thread.
|
||||
HWND hwnd = (HWND)window->window;
|
||||
_orig_window_proc = SetWindowLongPtr(hwnd, GWL_WNDPROC, (LONG_PTR)window_proc);
|
||||
|
||||
// Also set a timer to go off every once in a while, just in
|
||||
// case something slips through.
|
||||
SetTimer(hwnd, 1, 1000, NULL);
|
||||
}
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
|
@ -426,7 +430,6 @@ handle_request(P3D_request *request) {
|
|||
// with the proper P3D object pointer.
|
||||
P3D_object *obj = P3D_instance_get_panda_script_object(_p3d_inst);
|
||||
_script_object->set_p3d_object(obj);
|
||||
logfile << "got onpythonload\n";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -975,22 +978,23 @@ output_np_variant(ostream &out, const NPVariant &result) {
|
|||
////////////////////////////////////////////////////////////////////
|
||||
LONG PPInstance::
|
||||
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
|
||||
// If this is a toplevel window event, but not something caused as a
|
||||
// result of something done by handle_request_loop(), then call
|
||||
// handle_request_loop() to see if there are any new requests to be
|
||||
// forwarded to the main thread.
|
||||
static int recursion_protect = 0;
|
||||
++recursion_protect;
|
||||
if (recursion_protect == 1) {
|
||||
handle_request_loop();
|
||||
}
|
||||
--recursion_protect;
|
||||
// Since we're here in the main thread, call handle_request_loop()
|
||||
// to see if there are any new requests to be serviced by the main
|
||||
// thread.
|
||||
|
||||
// This might end up recursing repeatedly into
|
||||
// handle_request_loop(). Not sure if this is bad or not.
|
||||
// *Something* appears to be a little unstable.
|
||||
handle_request_loop();
|
||||
|
||||
switch (msg) {
|
||||
case WM_ERASEBKGND:
|
||||
// Eat the WM_ERASEBKGND message, so the browser's intervening
|
||||
// window won't overdraw on top of our own window.
|
||||
return true;
|
||||
|
||||
case WM_TIMER:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ has_method(NPIdentifier name) {
|
|||
string property_name = identifier_to_string(name);
|
||||
logfile << "has_method: " << this << ", " << property_name << "\n" << flush;
|
||||
|
||||
// As above, we always return true. Why not?
|
||||
// As below, we always return true. Why not?
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +218,7 @@ get_property(NPIdentifier name, NPVariant *result) {
|
|||
P3D_object *value = P3D_OBJECT_GET_PROPERTY(_p3d_object, property_name.c_str());
|
||||
if (value == NULL) {
|
||||
// No such property.
|
||||
logfile << " no such property\n" << flush;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -334,9 +334,9 @@ class AppRunner(DirectObject):
|
|||
# Now process any JavaScript that might be waiting for the
|
||||
# event as well. These are the JavaScript expressions that
|
||||
# were specified in the HTML embed or object tag.
|
||||
#expression = self.tokenDict.get(message)
|
||||
#if expression:
|
||||
# self.evalScript(expression)
|
||||
expression = self.tokenDict.get(message)
|
||||
if expression:
|
||||
self.evalScript(expression)
|
||||
|
||||
def evalScript(self, expression):
|
||||
""" Evaluates an arbitrary JavaScript expression in the global
|
||||
|
|
|
|||
Loading…
Reference in New Issue