From dcc96a60b1a7a6259c1e8f50595b242359fb8501 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Oct 2023 16:50:59 +0200 Subject: [PATCH 1/3] makepanda: Make version parsing in CreatePandaVersionFiles more robust --- makepanda/makepanda.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 23fd57afaa..1f4ca17321 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -3038,11 +3038,18 @@ END #endif""" def CreatePandaVersionFiles(): - version1=int(VERSION.split(".")[0]) - version2=int(VERSION.split(".")[1]) - version3=int(VERSION.split(".")[2]) - nversion=version1*1000000+version2*1000+version3 - if (DISTRIBUTOR != "cmu"): + parts = VERSION.split(".", 2) + version1 = int(parts[0]) + version2 = int(parts[1]) + version3 = 0 + if len(parts) > 2: + for c in parts[2]: + if c.isdigit(): + version3 = version3 * 10 + ord(c) - 48 + else: + break + nversion = version1 * 1000000 + version2 * 1000 + version3 + if DISTRIBUTOR != "cmu": # Subtract 1 if we are not an official version. nversion -= 1 From a2fa54f385171e2efe8fec762c3e1230fbff0b6d Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Oct 2023 16:52:45 +0200 Subject: [PATCH 2/3] gobj: fix `_contexts != nullptr` assert when prepare fails --- panda/src/gobj/geomVertexArrayData.cxx | 17 +++++++++++------ panda/src/gobj/shaderBuffer.cxx | 17 +++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/panda/src/gobj/geomVertexArrayData.cxx b/panda/src/gobj/geomVertexArrayData.cxx index 75a9a5db20..674c2182b6 100644 --- a/panda/src/gobj/geomVertexArrayData.cxx +++ b/panda/src/gobj/geomVertexArrayData.cxx @@ -239,19 +239,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { VertexBufferContext *GeomVertexArrayData:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == nullptr) { + if (_contexts != nullptr) { + Contexts::const_iterator ci; + ci = _contexts->find(prepared_objects); + if (ci != _contexts->end()) { + return (*ci).second; + } + } else { _contexts = new Contexts; } - Contexts::const_iterator ci; - ci = _contexts->find(prepared_objects); - if (ci != _contexts->end()) { - return (*ci).second; - } VertexBufferContext *vbc = prepared_objects->prepare_vertex_buffer_now(this, gsg); if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } + else if (_contexts->empty()) { + delete _contexts; + _contexts = nullptr; + } return vbc; } diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index fa16293d4d..9164a870ae 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -76,19 +76,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const { BufferContext *ShaderBuffer:: prepare_now(PreparedGraphicsObjects *prepared_objects, GraphicsStateGuardianBase *gsg) { - if (_contexts == nullptr) { + if (_contexts != nullptr) { + Contexts::const_iterator ci; + ci = _contexts->find(prepared_objects); + if (ci != _contexts->end()) { + return (*ci).second; + } + } else { _contexts = new Contexts; } - Contexts::const_iterator ci; - ci = _contexts->find(prepared_objects); - if (ci != _contexts->end()) { - return (*ci).second; - } BufferContext *vbc = prepared_objects->prepare_shader_buffer_now(this, gsg); if (vbc != nullptr) { (*_contexts)[prepared_objects] = vbc; } + else if (_contexts->empty()) { + delete _contexts; + _contexts = nullptr; + } return vbc; } From d5263b597b717606a44a3c2f2861d6458585f7bc Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 9 Oct 2023 17:02:33 +0200 Subject: [PATCH 3/3] makepanda: Strip version suffixes when parsing setup.cfg metadata Fixes #1539 --- makepanda/makepanda.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 1f4ca17321..407c95bb33 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -421,6 +421,12 @@ if VERSION is None: else: # Take the value from the setup.cfg file. VERSION = GetMetadataValue('version') + match = re.match(r'^\d+\.\d+(\.\d+)+', VERSION) + if not match: + exit("Invalid version %s in setup.cfg, three digits are required" % (VERSION)) + if WHLVERSION is None: + WHLVERSION = VERSION + VERSION = match.group() if WHLVERSION is None: WHLVERSION = VERSION