-
Bug
-
Resolution: Done
-
P1: Critical
-
5.5.1
-
None
-
f5af442
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({});
| For Gerrit Dashboard: QTBUG-51758 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V |
| 166059,4 | QVector: fix crash on reserve(0) | 5.6 | qt/qtbase | Status: MERGED | +2 | 0 |
| 181829,3 | QVector: fix crash on reserve(0) | tqtc/vxworks-5.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |