mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-08 04:50:07 +01:00
Add code to reinitialize the wxModules into an API function
This commit is contained in:
@@ -165,6 +165,7 @@ struct wxPyAPI {
|
||||
bool (*p_wxPyNumberSequenceCheck)(PyObject* obj, int reqLength);
|
||||
void* (*p_wxPyGetCppPtr)(sipSimpleWrapper* sipPyObj);
|
||||
PyObject* (*p_wxPyMethod_Self)(PyObject* method);
|
||||
void (*p_wxPyReinitializeModules)();
|
||||
|
||||
// Always add new items here at the end.
|
||||
};
|
||||
@@ -265,6 +266,11 @@ inline PyObject* wxPyMethod_Self(PyObject* method)
|
||||
{ return wxPyGetAPIPtr()->p_wxPyMethod_Self(method); }
|
||||
|
||||
|
||||
inline void wxPyReinitializeModules()
|
||||
{ return wxPyGetAPIPtr()->p_wxPyReinitializeModules(); }
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Convenience helper for RAII-style thread blocking
|
||||
|
||||
|
||||
@@ -528,6 +528,22 @@ inline PyObject* i_wxPyMethod_Self(PyObject* method) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Cleanup and reinitialize the wxModules. This is needed because sometimes an
|
||||
// Extension module will first be imported *after* the wx.App has been
|
||||
// created, so the wxModules in that extension will not have been registered
|
||||
// and initialized because they were not yet in memory.
|
||||
|
||||
void i_wxPyReinitializeModules() {
|
||||
if (i_wxPyCheckForApp(false)) {
|
||||
wxModule::CleanUpModules();
|
||||
wxModule::RegisterModules();
|
||||
wxModule::InitializeModules();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// An instance of the API structure
|
||||
static wxPyAPI API = {
|
||||
@@ -546,7 +562,8 @@ static wxPyAPI API = {
|
||||
i_wxPyMakeBuffer,
|
||||
i_wxPyNumberSequenceCheck,
|
||||
i_wxPyGetCppPtr,
|
||||
i_wxPyMethod_Self
|
||||
i_wxPyMethod_Self,
|
||||
i_wxPyReinitializeModules
|
||||
};
|
||||
%End
|
||||
|
||||
|
||||
Reference in New Issue
Block a user