You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/QtPython3/QtPython.cpp
+17-3Lines changed: 17 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -190,9 +190,23 @@ QtPython::~QtPython ( )
190
190
191
191
voidQtPython::preInitialize ( ) // CP v 5.1.0
192
192
{
193
-
// A faire avant Py_Initialize :
194
-
if (-1 == PyImport_AppendInittab ("redirector", PyInit_redirector))
195
-
throwException ("Echec de l'importation du module redirector par la console Python.");
193
+
staticbool preInitialized = false; // v 6.4.4
194
+
195
+
if (false == preInitialized)
196
+
{
197
+
// A faire avant Py_Initialize :
198
+
if (false == Py_IsInitialized ( ))
199
+
{
200
+
if (-1 == PyImport_AppendInittab ("redirector", PyInit_redirector))
201
+
throwException ("Echec de l'importation du module redirector par la console Python.");
202
+
}
203
+
else
204
+
// v 6.4.4. Eviter (python 3.12.5) : Fatal Python error: PyImport_AppendInittab: PyImport_AppendInittab() may not be called after Py_Initialize()
205
+
// Python runtime state: initialized
206
+
throwException ("QtPython::preInitialize doit être appelé avant Py_Initialize. PyImport_AppendInittab non appelé car l'application planterait. La console python ne devrait pas fonctionner correctement.");
0 commit comments