summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/changes-4.6.345
-rw-r--r--src/corelib/tools/qvarlengtharray.h15
-rw-r--r--tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp298
3 files changed, 350 insertions, 8 deletions
diff --git a/dist/changes-4.6.3 b/dist/changes-4.6.3
index 6ac0c7e..a332580 100644
--- a/dist/changes-4.6.3
+++ b/dist/changes-4.6.3
@@ -301,6 +301,51 @@ Qt for Symbian
- QtGui
* QUnixPrintWidget is no longer declared in Symbian.
* [QTBUG-10207]: Fixed long menu item texts causing crash.
+ * [QTBUG-9910] Fixed incorrect dialog position when native AVKON combined
+ status-and-control pane is in use.
+ * [QTBUG-4875] Made QMessageBox match size with native Symbian messageBox.
+ * [QTBUG-5539] Fixed QMessageBox to stretch to screen width with very small
+ content.
+ * [QTBUG-7828] Fixed Virtual keyboard closing issue with Sym^3.
+ * [QTBUG-9480] Use focus widget palette colors to show T9 suggested or
+ autocompletion words in QCoeFepInputContext.
+ * [QTBUG-10006] Changed default supported text modes to all, instead of just
+ lower and upper cases in QCoeFepInputContext.
+ * [QT-3277] Support text selection in QCoeFepInputContext for Sym^3.
+ * [QT-3008] Fixed crash in QGraphicsScenePrivate::setFocusItemHelper.
+
+ - QS60Style
+ * [QTBUG-10697] Support native-like selection in item views.
+ * [QTBUG-10454] Made styled sliders match in size to native sliders.
+ * [QTBUG-10073] Fixed QMenu with a lot of menu items.
+ * [QTBUG-3102] Fixed QTabWidget icon size issue.
+ * [QTBUG-5001] Show combobox list as a popup instead of dropdown list.
+ * [QTBUG-7258] Fixed calculations of PM_FocusFrameVMargin and
+ PM_FocusFrameHMargin pixel metrics.
+ * [QTBUG-7996] Fixed squeezed scrollbar handle and groove ends.
+ * [QTBUG-8193] Fixed drag-n-drop drop area drawing issue.
+ * [QTBUG-8194] Removed scrollbar context menu support.
+ * [QTBUG-8704] Fixed palette issues when drawing highlighted text.
+ * [QTBUG-9212] Fixed itemview multiselection issues.
+ * [QTBUG-9321] Fixed very large spinboxes drawing issues.
+ * [QTBUG-9837] Fixed text cutting issues with narrow QComboBoxes.
+ * [QTBUG-9844] Fixed QTreeView branch drawing issues in right to left
+ UI layout.
+ * [QTBUG-9927] Fixed transparent list higlight to show up correctly for
+ S60 3rd edition FP1 devices.
+ * [QTBUG-10064] Removed focus frame drawing for context menus and popups.
+ * [QTBUG-10487] Fixed QToolButton to be drawn pressed when context menu
+ for that button is open.
+ * [QTBUG-10549] Fixed style to honor stylesheet when drawing focus frame
+ for QPushButtons.
+ * [QT-3295] Made QMenu to look more native-like.
+ * [QT-3185] Fixed border frames to be drawn transparent for Sym^3 devices.
+ * [QT-3148] Draw application background correctly when animated wallpaper
+ is used in Sym^3 device.
+ * [QT-3137] Launch virtual keyboard with single tap.
+ * [QT-3104] Re-locate QTabWidget's scrollbuttons to either side of widget.
+ * [QT-2179] Fixed QPushButton with text and QPushButton with standard icon
+ to be of same size.
- Examples & demos:
* Enabled more examples by default in Symbian builds.
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index aecb66e..a70488f 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -128,9 +128,9 @@ private:
friend class QPodList<T, Prealloc>;
void realloc(int size, int alloc);
- int a;
- int s;
- T *ptr;
+ int a; // capacity
+ int s; // size
+ T *ptr; // data
union {
// ### Qt 5: Use 'Prealloc * sizeof(T)' as array size
char array[sizeof(qint64) * (((Prealloc * sizeof(T)) / sizeof(qint64)) + 1)];
@@ -193,8 +193,8 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
Q_ASSERT(aalloc >= asize);
T *oldPtr = ptr;
int osize = s;
- // s = asize;
+ const int copySize = qMin(asize, osize);
if (aalloc != a) {
ptr = reinterpret_cast<T *>(qMalloc(aalloc * sizeof(T)));
Q_CHECK_PTR(ptr);
@@ -205,7 +205,6 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
if (QTypeInfo<T>::isStatic) {
QT_TRY {
// copy all the old elements
- const int copySize = qMin(asize, osize);
while (s < copySize) {
new (ptr+s) T(*(oldPtr+s));
(oldPtr+s)->~T();
@@ -221,19 +220,19 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
QT_RETHROW;
}
} else {
- qMemCopy(ptr, oldPtr, qMin(asize, osize) * sizeof(T));
+ qMemCopy(ptr, oldPtr, copySize * sizeof(T));
}
} else {
ptr = oldPtr;
return;
}
}
+ s = copySize;
if (QTypeInfo<T>::isComplex) {
+ // destroy remaining old objects
while (osize > asize)
(oldPtr+(--osize))->~T();
- if (!QTypeInfo<T>::isStatic)
- s = osize;
}
if (oldPtr != reinterpret_cast<T *>(array) && oldPtr != ptr)
diff --git a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp
index 1c43069..39805e1 100644
--- a/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp
+++ b/tests/auto/qvarlengtharray/tst_qvarlengtharray.cpp
@@ -63,6 +63,7 @@ private slots:
void oldTests();
void task214223();
void QTBUG6718_resize();
+ void QTBUG10978_realloc();
};
int fooCtor = 0;
@@ -291,5 +292,302 @@ void tst_QVarLengthArray::QTBUG6718_resize()
}
}
+struct MyBase
+{
+ MyBase()
+ : data(this)
+ , isCopy(false)
+ {
+ ++liveCount;
+ }
+
+ MyBase(MyBase const &)
+ : data(this)
+ , isCopy(true)
+ {
+ ++copyCount;
+ ++liveCount;
+ }
+
+ MyBase & operator=(MyBase const &)
+ {
+ if (!isCopy) {
+ isCopy = true;
+ ++copyCount;
+ } else {
+ ++errorCount;
+ }
+
+ return *this;
+ }
+
+ ~MyBase()
+ {
+ if (isCopy) {
+ if (!copyCount)
+ ++errorCount;
+ else
+ --copyCount;
+ }
+
+ if (!liveCount)
+ ++errorCount;
+ else
+ --liveCount;
+ }
+
+ bool hasMoved() const
+ {
+ return this != data;
+ }
+
+protected:
+ MyBase const * const data;
+ bool isCopy;
+
+public:
+ static int errorCount;
+ static int liveCount;
+ static int copyCount;
+};
+
+int MyBase::errorCount = 0;
+int MyBase::liveCount = 0;
+int MyBase::copyCount = 0;
+
+struct MyPrimitive
+ : MyBase
+{
+ MyPrimitive()
+ {
+ ++errorCount;
+ }
+
+ ~MyPrimitive()
+ {
+ ++errorCount;
+ }
+
+ MyPrimitive(MyPrimitive const &other)
+ : MyBase(other)
+ {
+ ++errorCount;
+ }
+};
+
+struct MyMovable
+ : MyBase
+{
+};
+
+struct MyComplex
+ : MyBase
+{
+};
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_TYPEINFO(MyPrimitive, Q_PRIMITIVE_TYPE);
+Q_DECLARE_TYPEINFO(MyMovable, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO(MyComplex, Q_COMPLEX_TYPE);
+
+QT_END_NAMESPACE
+
+bool QTBUG10978_proceed = true;
+
+template <class T, int PreAlloc>
+int countMoved(QVarLengthArray<T, PreAlloc> const &c)
+{
+ int result = 0;
+ for (int i = 0; i < c.size(); ++i)
+ if (c[i].hasMoved())
+ ++result;
+
+ return result;
+}
+
+template <class T>
+void QTBUG10978_test()
+{
+ QTBUG10978_proceed = false;
+
+ typedef QVarLengthArray<T, 16> Container;
+ enum {
+ isStatic = QTypeInfo<T>::isStatic,
+ isComplex = QTypeInfo<T>::isComplex,
+
+ isPrimitive = !isComplex && !isStatic,
+ isMovable = !isStatic
+ };
+
+ // Constructors
+ Container a;
+ QCOMPARE( MyBase::liveCount, 0 );
+ QCOMPARE( MyBase::copyCount, 0 );
+
+ QVERIFY( a.capacity() >= 16 );
+ QCOMPARE( a.size(), 0 );
+
+ Container b_real(8);
+ Container const &b = b_real;
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 8 );
+ QCOMPARE( MyBase::copyCount, 0 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // Assignment
+ a = b;
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 16 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 8 : 0 );
+ QVERIFY( a.capacity() >= 16 );
+ QCOMPARE( a.size(), 8 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // append
+ a.append(b.data(), b.size());
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 24 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 16 : 0 );
+
+ QVERIFY( a.capacity() >= 16 );
+ QCOMPARE( a.size(), 16 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // removeLast
+ a.removeLast();
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
+
+ QVERIFY( a.capacity() >= 16 );
+ QCOMPARE( a.size(), 15 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // Movable types
+ const int capacity = a.capacity();
+ if (!isPrimitive)
+ QCOMPARE( countMoved(a), 0 );
+
+ // Reserve, no re-allocation
+ a.reserve(capacity);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(a), 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
+
+ QCOMPARE( a.capacity(), capacity );
+ QCOMPARE( a.size(), 15 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // Reserve, force re-allocation
+ a.reserve(capacity * 2);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(a), isMovable ? 15 : 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 23 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
+
+ QVERIFY( a.capacity() >= capacity * 2 );
+ QCOMPARE( a.size(), 15 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // resize, grow
+ a.resize(40);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(a), isMovable ? 15 : 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 48 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 15 : 0 );
+
+ QVERIFY( a.capacity() >= a.size() );
+ QCOMPARE( a.size(), 40 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // Copy constructor, allocate
+ {
+ Container c(a);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(c), 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 88 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 55 : 0 );
+
+ QVERIFY( a.capacity() >= a.size() );
+ QCOMPARE( a.size(), 40 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ QVERIFY( c.capacity() >= 40 );
+ QCOMPARE( c.size(), 40 );
+ }
+
+ // resize, shrink
+ a.resize(10);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(a), isMovable ? 10 : 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 18 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 10 : 0 );
+
+ QVERIFY( a.capacity() >= a.size() );
+ QCOMPARE( a.size(), 10 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ // Copy constructor, don't allocate
+ {
+ Container c(a);
+ if (!isPrimitive)
+ QCOMPARE( countMoved(c), 0 );
+ QCOMPARE( MyBase::liveCount, isPrimitive ? 0 : 28 );
+ QCOMPARE( MyBase::copyCount, isComplex ? 20 : 0 );
+
+ QVERIFY( a.capacity() >= a.size() );
+ QCOMPARE( a.size(), 10 );
+
+ QVERIFY( b.capacity() >= 16 );
+ QCOMPARE( b.size(), 8 );
+
+ QVERIFY( c.capacity() >= 16 );
+ QCOMPARE( c.size(), 10 );
+ }
+
+ a.clear();
+ QCOMPARE( a.size(), 0 );
+
+ b_real.clear();
+ QCOMPARE( b.size(), 0 );
+
+ QCOMPARE(MyBase::errorCount, 0);
+ QCOMPARE(MyBase::liveCount, 0);
+
+ // All done
+ QTBUG10978_proceed = true;
+}
+
+void tst_QVarLengthArray::QTBUG10978_realloc()
+{
+ QTBUG10978_test<MyBase>();
+ QVERIFY(QTBUG10978_proceed);
+
+ QTBUG10978_test<MyPrimitive>();
+ QVERIFY(QTBUG10978_proceed);
+
+ QTBUG10978_test<MyMovable>();
+ QVERIFY(QTBUG10978_proceed);
+
+ QTBUG10978_test<MyComplex>();
+ QVERIFY(QTBUG10978_proceed);
+}
+
QTEST_APPLESS_MAIN(tst_QVarLengthArray)
#include "tst_qvarlengtharray.moc"