inline void detach() { if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
- inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+ inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QHashData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QHash<Key, T> &other) const { return d == other.d; }
void clear();
inline void detach()
{ if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
- inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+ inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QLinkedList<T> &other) const { return d == other.d; }
inline bool isEmpty() const { return d->size == 0; }
}
inline bool isDetached() const { return d->ref == 1; }
- inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+ inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QListData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QList<T> &other) const { return d == other.d; }
inline bool isEmpty() const { return p.isEmpty(); }
inline void detach() { if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
- inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+ inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QMapData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QMap<Key, T> &other) const { return d == other.d; }
- inline void setInsertInOrder(bool ordered) { d->insertInOrder = ordered; }
+ inline void setInsertInOrder(bool ordered) { if (ordered) detach(); if (d != &QMapData::shared_null) d->insertInOrder = ordered; }
void clear();
inline void detach() { if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
- inline void setSharable(bool sharable) { if (!sharable) detach(); d->sharable = sharable; }
+ inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QVectorData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
inline T *data() { detach(); return p->array; }
void iterators(); // sligthly modified from tst_QMap
void keys_values_uniqueKeys(); // slightly modified from tst_QMap
void noNeedlessRehashes();
+
+ void const_shared_null();
};
struct Foo {
}
}
+void tst_QHash::const_shared_null()
+{
+ QHash<int, QString> hash1;
+ hash1.setSharable(false);
+ QVERIFY(hash1.isDetached());
+
+ QHash<int, QString> hash2;
+ hash2.setSharable(true);
+ QVERIFY(!hash2.isDetached());
+}
+
QTEST_APPLESS_MAIN(tst_QHash)
#include "tst_qhash.moc"
void testOperators() const;
void initializeList() const;
+
+ void const_shared_null() const;
};
void tst_QList::length() const
#endif
}
+void tst_QList::const_shared_null() const
+{
+ QList<int> list1;
+ list1.setSharable(false);
+ QVERIFY(list1.isDetached());
+
+ QList<int> list2;
+ list2.setSharable(true);
+ QVERIFY(!list2.isDetached());
+}
+
QTEST_APPLESS_MAIN(tst_QList)
#include "tst_qlist.moc"
void iterators();
void keys_values_uniqueKeys();
void qmultimap_specific();
+
+ void const_shared_null();
};
tst_QMap::tst_QMap()
}
}
+void tst_QMap::const_shared_null()
+{
+ QMap<int, QString> map1;
+ map1.setSharable(false);
+ QVERIFY(map1.isDetached());
+
+ QMap<int, QString> map2;
+ map2.setSharable(true);
+ QVERIFY(!map2.isDetached());
+
+ QMap<int, QString> map3;
+ map3.setInsertInOrder(true);
+ map3.setInsertInOrder(false);
+}
+
QTEST_APPLESS_MAIN(tst_QMap)
#include "tst_qmap.moc"
void QTBUG11763_data();
void QTBUG11763();
void initializeList();
+
+ void const_shared_null();
};
void tst_QVector::constructors() const
#endif
}
+void tst_QVector::const_shared_null()
+{
+ QVector<int> v1;
+ v1.setSharable(false);
+ QVERIFY(v1.isDetached());
+
+ QVector<int> v2;
+ v2.setSharable(true);
+ QVERIFY(!v2.isDetached());
+}
+
QTEST_APPLESS_MAIN(tst_QVector)
#include "tst_qvector.moc"