Skip to content

Commit eebccea

Browse files
v-einhoffstadt
authored andcommitted
fix: Deletion of an item still hanging in the container stack no longer causes a segfault.
1 parent 0432fd1 commit eebccea

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/dearpygui_commands.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2933,10 +2933,10 @@ pop_container_stack(PyObject* self, PyObject* args, PyObject* kwargs)
29332933
return nullptr;
29342934
}
29352935

2936-
mvAppItem* item = containers.top();
2936+
PyObject* top = ToPyUUIDOrNone(containers.top().get());
29372937
containers.pop();
29382938

2939-
return ToPyUUIDOrNone(item);
2939+
return top;
29402940

29412941
}
29422942

@@ -2958,7 +2958,7 @@ top_container_stack(PyObject* self, PyObject* args, PyObject* kwargs)
29582958
mvAppItem* item = nullptr;
29592959
auto& containers = mvItemRegistry::threadContext.containers;
29602960
if (!containers.empty())
2961-
item = containers.top();
2961+
item = containers.top().get();
29622962

29632963
return ToPyUUIDOrNone(item);
29642964
}
@@ -2999,7 +2999,7 @@ push_container_stack(PyObject* self, PyObject* args, PyObject* kwargs)
29992999

30003000
mvUUID item = GetIDFromPyObject(itemraw);
30013001

3002-
mvAppItem* parent = GetItem((*GContext->itemRegistry), item);
3002+
auto parent = GetRefItem((*GContext->itemRegistry), item);
30033003
if (parent)
30043004
{
30053005
if (DearPyGui::GetEntityDesciptionFlags(parent->type) & MV_ITEM_DESC_CONTAINER)

src/mvItemRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ TopParent(mvItemRegistry& registry)
4343
{
4444
auto& containers = mvItemRegistry::threadContext.containers;
4545
if (!containers.empty())
46-
return containers.top();
46+
return containers.top().get();
4747
return nullptr;
4848
}
4949

src/mvItemRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct mvThreadContext
6060
mvUUID lastContainerAdded = 0;
6161
mvUUID lastRootAdded = 0;
6262

63-
std::stack<mvAppItem*> containers; // parent stack, top of stack becomes widget's parent
63+
std::stack<std::shared_ptr<mvAppItem>> containers; // parent stack, top of stack becomes widget's parent
6464

6565
std::shared_ptr<mvAppItem> capturedItem = nullptr;
6666
mvPyObject captureCallback = nullptr;

0 commit comments

Comments
 (0)