I’m creating a program where in I will be selecting points on a grid and dynamically generating line segments between those points using panda’s GeomLine primitives. My plan is to delete the existing custom geometry and make new geometry whenever a point is added, removed, etc. I want to verify that my code is going to garbage collect everything from the old geometry when I prepare to create new geometry. Here is the code I’m using:
Is this means that clearing of geometry data before removeNode is wrong or unnecessary(clearRows(vertex data), clearVertices and clearPrimitives)? I`m getting a segfault and I found that clearing of data before removing node is the thing that causes this. My code is similar but I draw triangles.
Program received signal SIGSEGV, Segmentation fault.
0x0128673e in GeomPrimitive::get_data_size_bytes() const () from /usr/lib/panda3d/libpanda.so
(gdb) backtrace
#0 0x0128673e in GeomPrimitive::get_data_size_bytes() const () from /usr/lib/panda3d/libpanda.so
#1 0x01247027 in PreparedGraphicsObjects::release_index_buffer(IndexBufferContext*) () from /usr/lib/panda3d/libpanda.so
#2 0x011ccdaa in GeomPrimitive::release_all() () from /usr/lib/panda3d/libpanda.so
#3 0x011e15c6 in GeomPrimitive::~GeomPrimitive() () from /usr/lib/panda3d/libpanda.so
#4 0x011e1853 in GeomTriangles::~GeomTriangles() () from /usr/lib/panda3d/libpanda.so
#5 0x01297234 in Dtool_FreeInstance_GeomTriangles(_object*) () from /usr/lib/panda3d/libpanda.so
#6 0x00bf3ce6 in Dtool_Deallocate_General(_object*) () from /usr/lib/panda3d/libpanda.so
#7 0x0808db04 in dict_dealloc (mp=0x8d6ef0c) at ../Objects/dictobject.c:911
#8 0x0806a18b in instance_dealloc (inst=0x8d6c64c) at ../Objects/classobject.c:668
...
Clearing of geometry data is indeed completely unnecessary; it will be cleaned up automatically when the node goes away. Still, it shouldn’t cause a crash. That might be a bug, can you show a sample program that demonstrates the crash?
Sorry for my late answer. I have few days off. So today I found the problem and its not a panda bug. I have kept a references to all data(vertex data, primitive and geom). So, its wrong to modify data explicitly from these references(even for a cleaning only).