Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.5.1
-
None
-
f5af442
Description
Crashes when reserving a QVector capacity after erasing all vector items.
std::vector<int> v; v.erase(v.begin(), v.end()); v.reserve(0); // Ok QVector<int> v2; v2.erase(v2.begin(), v2.end()); v2.reserve(0); // Crash
My real example was:
struct ViewList { typedef BaseView type_t; typedef QSharedPointer<type_t> item_t; typedef QVector<item_t> items_t; private: items_t m_items; public: void init(std::initializer_list<item_t> items) { m_items.erase(m_items.begin(), m_items.end()); m_items.reserve(items.size()); foreach(auto const& item, items) m_items.push_back(item); } }; ViewList list; list.init({});