mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
redirect to main thread
This commit is contained in:
parent
23ab03ec91
commit
0f21af3a53
@ -508,7 +508,9 @@ add_raw_request(TiXmlDocument *doc) {
|
|||||||
// Tell the world we've got a new request.
|
// Tell the world we've got a new request.
|
||||||
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
|
||||||
inst_mgr->signal_request_ready(this);
|
inst_mgr->signal_request_ready(this);
|
||||||
_session->signal_request_ready(this);
|
if (_session != NULL) {
|
||||||
|
_session->signal_request_ready(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -881,13 +883,36 @@ make_xml() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: P3DInstance::splash_button_clicked
|
// Function: P3DInstance::splash_button_clicked_sub_thread
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: Called by the P3DSplashWindow code when the user
|
// Description: Called by the P3DSplashWindow code (maybe in a
|
||||||
// clicks the button visible on the splash window.
|
// sub-thread) when the user clicks the button visible
|
||||||
|
// on the splash window. This will forward the event to
|
||||||
|
// the main thread via the request callback mechanism.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void P3DInstance::
|
void P3DInstance::
|
||||||
splash_button_clicked() {
|
splash_button_clicked_sub_thread() {
|
||||||
|
cerr << "splash sub\n";
|
||||||
|
TiXmlDocument *doc = new TiXmlDocument;
|
||||||
|
TiXmlElement *xrequest = new TiXmlElement("request");
|
||||||
|
xrequest->SetAttribute("rtype", "notify");
|
||||||
|
xrequest->SetAttribute("message", "buttonclick");
|
||||||
|
doc->LinkEndChild(xrequest);
|
||||||
|
|
||||||
|
add_raw_request(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: P3DInstance::splash_button_clicked_main_thread
|
||||||
|
// Access: Public
|
||||||
|
// Description: Called only in the main thread, indirectly from
|
||||||
|
// splash_button_clicked_sub_thread(), as the result of
|
||||||
|
// the user clicking on the button visible in the splash
|
||||||
|
// window.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void P3DInstance::
|
||||||
|
splash_button_clicked_main_thread() {
|
||||||
|
cerr << "splash main\n";
|
||||||
if (!_p3d_trusted) {
|
if (!_p3d_trusted) {
|
||||||
auth_button_clicked();
|
auth_button_clicked();
|
||||||
} else if (_session == NULL) {
|
} else if (_session == NULL) {
|
||||||
@ -954,6 +979,17 @@ check_p3d_signature() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (_browser_script_object != NULL) {
|
||||||
|
P3D_object *result = P3D_OBJECT_EVAL(_browser_script_object, "if (confirm('test')) { window.open('', 'test', ''); }");
|
||||||
|
cerr << "result = " << result << "\n";
|
||||||
|
if (result != NULL) {
|
||||||
|
cerr << "formatted: " << *result << "\n";
|
||||||
|
P3D_OBJECT_DECREF(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Temporary hack: disabling further security checks until this code
|
// Temporary hack: disabling further security checks until this code
|
||||||
// is complete.
|
// is complete.
|
||||||
return true;
|
return true;
|
||||||
@ -1298,6 +1334,14 @@ handle_notify_request(const string &message) {
|
|||||||
CFRunLoopRef run_loop = CFRunLoopGetCurrent();
|
CFRunLoopRef run_loop = CFRunLoopGetCurrent();
|
||||||
CFRunLoopAddTimer(run_loop, _frame_timer, kCFRunLoopCommonModes);
|
CFRunLoopAddTimer(run_loop, _frame_timer, kCFRunLoopCommonModes);
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
} else if (message == "buttonclick") {
|
||||||
|
// We just got a special "button click" message from the
|
||||||
|
// sub-thread. This case is a little unusual, as it came from the
|
||||||
|
// splash window and not from Python (we presumably haven't even
|
||||||
|
// started Python yet). We use this as a sneaky way to forward
|
||||||
|
// the event from the sub-thread to the main thread.
|
||||||
|
splash_button_clicked_main_thread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,8 @@ public:
|
|||||||
void request_refresh();
|
void request_refresh();
|
||||||
|
|
||||||
TiXmlElement *make_xml();
|
TiXmlElement *make_xml();
|
||||||
void splash_button_clicked();
|
void splash_button_clicked_sub_thread();
|
||||||
|
void splash_button_clicked_main_thread();
|
||||||
void auth_button_clicked();
|
void auth_button_clicked();
|
||||||
void play_button_clicked();
|
void play_button_clicked();
|
||||||
|
|
||||||
|
@ -473,11 +473,13 @@ set_mouse_data(int mouse_x, int mouse_y, bool mouse_down) {
|
|||||||
// notifies the instance. It's a virtual method to give
|
// notifies the instance. It's a virtual method to give
|
||||||
// subclasses a chance to redirect this message to the
|
// subclasses a chance to redirect this message to the
|
||||||
// main thread or process, as necessary.
|
// main thread or process, as necessary.
|
||||||
|
//
|
||||||
|
// Note that this method might be called in a sub-thread.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void P3DSplashWindow::
|
void P3DSplashWindow::
|
||||||
button_click_detected() {
|
button_click_detected() {
|
||||||
assert(_inst != NULL);
|
assert(_inst != NULL);
|
||||||
_inst->splash_button_clicked();
|
_inst->splash_button_clicked_sub_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -220,12 +220,7 @@ unregister_window_class() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void P3DWinSplashWindow::
|
void P3DWinSplashWindow::
|
||||||
button_click_detected() {
|
button_click_detected() {
|
||||||
// Since this message is detected in the sub-thread in the Windows
|
|
||||||
// case, we have to protect ourselves from re-entry by grabbing the
|
|
||||||
// global _api_lock.
|
|
||||||
ACQUIRE_LOCK(_api_lock);
|
|
||||||
P3DSplashWindow::button_click_detected();
|
P3DSplashWindow::button_click_detected();
|
||||||
RELEASE_LOCK(_api_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -440,9 +440,7 @@ rt_handle_request(TiXmlDocument *doc) {
|
|||||||
// click notification.
|
// click notification.
|
||||||
delete doc;
|
delete doc;
|
||||||
|
|
||||||
ACQUIRE_LOCK(_api_lock);
|
|
||||||
P3DSplashWindow::button_click_detected();
|
P3DSplashWindow::button_click_detected();
|
||||||
RELEASE_LOCK(_api_lock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user