diff --git a/rpcs3/rpcs3qt/flow_layout.cpp b/rpcs3/rpcs3qt/flow_layout.cpp index 02fcbd1a34..92fe956b28 100644 --- a/rpcs3/rpcs3qt/flow_layout.cpp +++ b/rpcs3/rpcs3qt/flow_layout.cpp @@ -79,7 +79,8 @@ flow_layout::~flow_layout() void flow_layout::clear() { - for (QLayoutItem* item : m_item_list) + // We can't use a ranged loop here, since deleting the widget will call takeAt on the layout. So let's also use takeAt. + while (QLayoutItem* item = takeAt(0)) { if (item) {