diff --git a/plugins/flutter/CHANGELOG.md b/plugins/flutter/CHANGELOG.md index 33ba1e31..e655b8e9 100644 --- a/plugins/flutter/CHANGELOG.md +++ b/plugins/flutter/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.5.0+5 +## 0.5.0+6 + Fix a bug of crash when using multi-thread diff --git a/plugins/flutter/pubspec.yaml b/plugins/flutter/pubspec.yaml index 4974d13c..b9d2a885 100644 --- a/plugins/flutter/pubspec.yaml +++ b/plugins/flutter/pubspec.yaml @@ -1,6 +1,6 @@ name: pocketpy description: A lightweight Python interpreter for game engines. -version: 0.5.0+5 +version: 0.5.0+6 homepage: https://pocketpy.dev repository: https://github.com/blueloveth/pocketpy diff --git a/plugins/flutter/src/pocketpy.h b/plugins/flutter/src/pocketpy.h index 7b4b07bf..abee116a 100644 --- a/plugins/flutter/src/pocketpy.h +++ b/plugins/flutter/src/pocketpy.h @@ -2307,7 +2307,7 @@ public: namespace pkpy { const uint8_t MAX_POOLING_N = 10; - static std::vector* _poolArgList = new std::vector[MAX_POOLING_N]; + static thread_local std::vector* _poolArgList = new std::vector[MAX_POOLING_N]; class ArgList { PyVar* _args = nullptr; @@ -2428,7 +2428,7 @@ namespace pkpy { }; const ArgList& noArg(){ - static ArgList ret(0); + static const ArgList ret(0); return ret; } @@ -3865,7 +3865,7 @@ public: Frame(const CodeObject* code, PyVar _module, PyVarDict&& locals) : code(code), _module(_module), f_locals(std::move(locals)) { - static uint64_t frame_id = 1; + static thread_local uint64_t frame_id = 1; id = frame_id++; } diff --git a/plugins/godot/godot-cpp b/plugins/godot/godot-cpp index 5e4cc4c4..489e88e8 160000 --- a/plugins/godot/godot-cpp +++ b/plugins/godot/godot-cpp @@ -1 +1 @@ -Subproject commit 5e4cc4c44a5b65a9ea53e038ffb7c83591d27698 +Subproject commit 489e88e885effa484134f98db933ca45659c2026 diff --git a/src/codeobject.h b/src/codeobject.h index bc36ae24..75663d0b 100644 --- a/src/codeobject.h +++ b/src/codeobject.h @@ -143,7 +143,7 @@ public: Frame(const CodeObject* code, PyVar _module, PyVarDict&& locals) : code(code), _module(_module), f_locals(std::move(locals)) { - static uint64_t frame_id = 1; + static thread_local uint64_t frame_id = 1; id = frame_id++; } diff --git a/src/safestl.h b/src/safestl.h index 778bb347..48546153 100644 --- a/src/safestl.h +++ b/src/safestl.h @@ -64,7 +64,7 @@ public: namespace pkpy { const uint8_t MAX_POOLING_N = 10; - static std::vector* _poolArgList = new std::vector[MAX_POOLING_N]; + static thread_local std::vector* _poolArgList = new std::vector[MAX_POOLING_N]; class ArgList { PyVar* _args = nullptr; @@ -185,7 +185,7 @@ namespace pkpy { }; const ArgList& noArg(){ - static ArgList ret(0); + static const ArgList ret(0); return ret; }