summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-20 18:32:18 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-20 18:32:18 (GMT)
commit471638950e8e3a63ceb0474f3b792112ebb46aba (patch)
tree3ef1ade022144ed961b6ce3e0c66ce52d9d0bfbc
parentdfc61f6b59886f7d223722bf149342cdd46581a8 (diff)
parentef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72 (diff)
downloadQt-471638950e8e3a63ceb0474f3b792112ebb46aba.zip
Qt-471638950e8e3a63ceb0474f3b792112ebb46aba.tar.gz
Qt-471638950e8e3a63ceb0474f3b792112ebb46aba.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix crash when using fonts in non-gui QApplication Deselect the current selection when the QItemSelectionModel::model is reset. Autotest fix on macosx Compile with gcc 4.0.1 improve Unicode Normalization autotest more subtests for QChar nano optimization of canonicalOrderHelper() fix canonicalOrderHelper() for some corner case use new QChar::requiresSurrogates() instead of hardcoded value prevent fake normalization prefer QChar::*surrogate() over hardcoded values Fixed an assert in QMenu
-rw-r--r--src/corelib/tools/qchar.cpp38
-rw-r--r--src/corelib/tools/qstring.cpp12
-rw-r--r--src/gui/image/qicon.cpp3
-rw-r--r--src/gui/itemviews/qitemselectionmodel.cpp25
-rw-r--r--src/gui/itemviews/qitemselectionmodel.h1
-rw-r--r--src/gui/itemviews/qitemselectionmodel_p.h3
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp2
-rw-r--r--src/gui/styles/qcommonstyle.cpp3
-rw-r--r--src/gui/styles/qmacstyle_mac.mm2
-rw-r--r--src/gui/styles/qplastiquestyle.cpp2
-rw-r--r--src/gui/styles/qproxystyle.cpp2
-rw-r--r--src/gui/styles/qstyle_p.h1
-rw-r--r--src/gui/styles/qstylehelper.cpp3
-rw-r--r--src/gui/styles/qwindowsstyle.cpp8
-rw-r--r--src/gui/text/qfontdatabase_x11.cpp7
-rw-r--r--src/gui/widgets/qmenu.cpp12
-rw-r--r--tests/auto/qchar/tst_qchar.cpp104
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp47
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp54
19 files changed, 245 insertions, 84 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index ddb1516..ed0af4e 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -1480,9 +1480,9 @@ static void decomposeHelper(QString *str, bool canonical, QChar::UnicodeVersion
if (!d || (canonical && tag != QChar::Canonical))
continue;
- s.replace(uc - utf16, ucs4 > 0x10000 ? 2 : 1, (const QChar *)d, length);
- // since the insert invalidates the pointers and we do decomposition recursive
int pos = uc - utf16;
+ s.replace(pos, QChar::requiresSurrogates(ucs4) ? 2 : 1, reinterpret_cast<const QChar *>(d), length);
+ // since the insert invalidates the pointers and we do decomposition recursive
utf16 = reinterpret_cast<unsigned short *>(s.data());
uc = utf16 + pos + length;
}
@@ -1567,46 +1567,52 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
int p2 = pos+1;
uint u1 = s.at(pos).unicode();
if (QChar(u1).isHighSurrogate()) {
- ushort low = s.at(pos+1).unicode();
+ ushort low = s.at(p2).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u1 = QChar::surrogateToUcs4(u1, low);
if (p2 >= l)
break;
+ ++p2;
}
}
uint u2 = s.at(p2).unicode();
- if (QChar(u2).isHighSurrogate() && p2 < l-1) {
+ if (QChar(u2).isHighSurrogate() && p2 < l) {
ushort low = s.at(p2+1).unicode();
if (QChar(low).isLowSurrogate()) {
- p2++;
u2 = QChar::surrogateToUcs4(u2, low);
+ ++p2;
}
}
- int c2 = QChar::combiningClass(u2);
- if (QChar::unicodeVersion(u2) > version)
- c2 = 0;
-
+ ushort c2 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u2);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c2 = p->combiningClass;
+ }
if (c2 == 0) {
pos = p2+1;
continue;
}
- int c1 = QChar::combiningClass(u1);
- if (QChar::unicodeVersion(u1) > version)
- c1 = 0;
+
+ ushort c1 = 0;
+ {
+ const QUnicodeTables::Properties *p = qGetProp(u1);
+ if ((QChar::UnicodeVersion)p->unicodeVersion <= version)
+ c1 = p->combiningClass;
+ }
if (c1 > c2) {
QChar *uc = s.data();
int p = pos;
// exchange characters
- if (u2 < 0x10000) {
+ if (!QChar::requiresSurrogates(u2)) {
uc[p++] = u2;
} else {
uc[p++] = QChar::highSurrogate(u2);
uc[p++] = QChar::lowSurrogate(u2);
}
- if (u1 < 0x10000) {
+ if (!QChar::requiresSurrogates(u1)) {
uc[p++] = u1;
} else {
uc[p++] = QChar::highSurrogate(u1);
@@ -1618,7 +1624,7 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in
--pos;
} else {
++pos;
- if (u1 > 0x10000)
+ if (QChar::requiresSurrogates(u1))
++pos;
}
}
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 612c492..6acbcec 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -939,11 +939,11 @@ int QString::toWCharArray(wchar_t *array) const
const unsigned short *uc = utf16();
for (int i = 0; i < length(); ++i) {
uint u = uc[i];
- if (u >= 0xd800 && u < 0xdc00 && i < length()-1) {
+ if (QChar::isHighSurrogate(u) && i + 1 < length()) {
ushort low = uc[i+1];
- if (low >= 0xdc00 && low < 0xe000) {
+ if (QChar::isLowSurrogate(low)) {
+ u = QChar::surrogateToUcs4(u, low);
++i;
- u = (u - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
}
}
*a = wchar_t(u);
@@ -6195,8 +6195,10 @@ void qt_string_normalize(QString *data, QString::NormalizationForm mode, QChar::
if (simple)
return;
- QString &s = *data;
- if (version != UNICODE_DATA_VERSION) {
+ if (version == QChar::Unicode_Unassigned) {
+ version = UNICODE_DATA_VERSION;
+ } else if (version != UNICODE_DATA_VERSION) {
+ QString &s = *data;
for (int i = 0; i < NumNormalizationCorrections; ++i) {
const NormalizationCorrection &n = uc_normalization_corrections[i];
if (n.version > version) {
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 7696632..a2f429a 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -55,7 +55,6 @@
#include "qcache.h"
#include "qdebug.h"
#include "private/qguiplatformplugin_p.h"
-#include "private/qstylehelper_p.h"
#ifdef Q_WS_MAC
#include <private/qt_mac_p.h>
@@ -67,6 +66,8 @@
#include "private/qkde_p.h"
#endif
+#include "private/qstylehelper_p.h"
+
#ifndef QT_NO_ICON
QT_BEGIN_NAMESPACE
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp
index f848321..fc99439 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/gui/itemviews/qitemselectionmodel.cpp
@@ -566,6 +566,8 @@ void QItemSelectionModelPrivate::initModel(QAbstractItemModel *model)
q, SLOT(_q_layoutAboutToBeChanged()));
QObject::connect(model, SIGNAL(layoutChanged()),
q, SLOT(_q_layoutChanged()));
+ QObject::connect(model, SIGNAL(modelAboutToBeReset()),
+ q, SLOT(_q_modelAboutToBeReset()));
}
}
@@ -896,6 +898,13 @@ void QItemSelectionModelPrivate::_q_layoutChanged()
savedPersistentCurrentIndexes.clear();
}
+void QItemSelectionModelPrivate::_q_modelAboutToBeReset()
+{
+ Q_Q(QItemSelectionModel);
+ q->clearSelection();
+ clearCurrentIndex();
+}
+
/*!
\class QItemSelectionModel
@@ -1095,12 +1104,18 @@ void QItemSelectionModel::clear()
{
Q_D(QItemSelectionModel);
clearSelection();
- QModelIndex previous = d->currentIndex;
- d->currentIndex = QModelIndex();
+ d->clearCurrentIndex();
+}
+
+void QItemSelectionModelPrivate::clearCurrentIndex()
+{
+ Q_Q(QItemSelectionModel);
+ QModelIndex previous = currentIndex;
+ currentIndex = QModelIndex();
if (previous.isValid()) {
- emit currentChanged(d->currentIndex, previous);
- emit currentRowChanged(d->currentIndex, previous);
- emit currentColumnChanged(d->currentIndex, previous);
+ emit q->currentChanged(currentIndex, previous);
+ emit q->currentRowChanged(currentIndex, previous);
+ emit q->currentColumnChanged(currentIndex, previous);
}
}
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/gui/itemviews/qitemselectionmodel.h
index 436514f..8682109 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/gui/itemviews/qitemselectionmodel.h
@@ -197,6 +197,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_rowsAboutToBeInserted(const QModelIndex&, int, int))
Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/gui/itemviews/qitemselectionmodel_p.h
index 5afa90d..c2fe976 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/gui/itemviews/qitemselectionmodel_p.h
@@ -78,6 +78,7 @@ public:
void _q_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
void _q_layoutAboutToBeChanged();
void _q_layoutChanged();
+ void _q_modelAboutToBeReset();
inline void remove(QList<QItemSelectionRange> &r)
{
@@ -93,6 +94,8 @@ public:
currentSelection.clear();
}
+ void clearCurrentIndex();
+
QPointer<QAbstractItemModel> model;
QItemSelection ranges;
QItemSelection currentSelection;
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index d9f7df0..883f511 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -44,7 +44,6 @@
#if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN)
-#include <private/qstylehelper_p.h>
#include "qwindowsstyle_p.h"
#include <qcombobox.h>
#include <qpushbutton.h>
@@ -67,6 +66,7 @@
#include <qtoolbar.h>
#include <qwizard.h>
#include <qlibrary.h>
+#include <private/qstylehelper_p.h>
#define CL_MAX(a,b) (a)>(b) ? (a):(b) // ### qMin/qMax does not work for vc6
#define CL_MIN(a,b) (a)<(b) ? (a):(b) // remove this when it is working
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 8036728..4978565 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -65,7 +65,6 @@
#include <qrubberband.h>
#include <private/qcommonstylepixmaps_p.h>
#include <private/qmath_p.h>
-#include <private/qstylehelper_p.h>
#include <qdebug.h>
#include <qtextformat.h>
#include <qwizard.h>
@@ -88,6 +87,8 @@
# include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#include <private/qstylehelper_p.h>
+
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index e065bcc..2e2f374 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -56,7 +56,6 @@
#include <private/qpaintengine_mac_p.h>
#include <private/qpainter_p.h>
#include <private/qprintengine_mac_p.h>
-#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qcheckbox.h>
@@ -101,6 +100,7 @@
#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
#include <private/qt_cocoa_helpers_mac_p.h>
+#include <private/qstylehelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index fbb5e4d..c8711f6 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -50,7 +50,6 @@ static const int ProgressBarFps = 25;
static const int blueFrameWidth = 2; // with of line edit focus frame
#include "qwindowsstyle_p.h"
-#include <private/qstylehelper_p.h>
#include <qapplication.h>
#include <qbitmap.h>
#include <qabstractitemview.h>
@@ -88,6 +87,7 @@ static const int blueFrameWidth = 2; // with of line edit focus frame
#include <qprocess.h>
#include <qvarlengtharray.h>
#include <limits.h>
+#include <private/qstylehelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qproxystyle.cpp b/src/gui/styles/qproxystyle.cpp
index 5235350..511c025 100644
--- a/src/gui/styles/qproxystyle.cpp
+++ b/src/gui/styles/qproxystyle.cpp
@@ -40,11 +40,11 @@
****************************************************************************/
#include <qstyle.h>
-#include <private/qstyle_p.h>
#include <private/qproxystyle_p.h>
#include <private/qapplication_p.h>
#include "qproxystyle.h"
#include "qstylefactory.h"
+#include <private/qstyle_p.h>
#if !defined(QT_NO_STYLE_PROXY) || defined(QT_PLUGIN)
diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h
index 4729032..745092f 100644
--- a/src/gui/styles/qstyle_p.h
+++ b/src/gui/styles/qstyle_p.h
@@ -43,7 +43,6 @@
#define QSTYLE_P_H
#include "private/qobject_p.h"
-#include "private/qstylehelper_p.h"
#include <QtGui/qstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp
index d09d7fa..ccdbf8c 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/gui/styles/qstylehelper.cpp
@@ -39,8 +39,6 @@
**
****************************************************************************/
-#include "qstylehelper_p.h"
-
#include <qstyleoption.h>
#include <qpainter.h>
#include <qpixmapcache.h>
@@ -54,6 +52,7 @@
#include <private/qt_cocoa_helpers_mac_p.h>
#endif
+#include "qstylehelper_p.h"
#include <qstringbuilder.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 1653baa..0314c6f 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -41,7 +41,6 @@
#include "qwindowsstyle.h"
#include "qwindowsstyle_p.h"
-#include <private/qstylehelper_p.h>
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
@@ -70,13 +69,14 @@
#include <private/qmath_p.h>
#include <qmath.h>
-
#ifdef Q_WS_X11
#include "qfileinfo.h"
#include "qdir.h"
#include <private/qt_x11_p.h>
#endif
+#include <private/qstylehelper_p.h>
+
QT_BEGIN_NAMESPACE
#if defined(Q_WS_WIN)
@@ -1911,7 +1911,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
p->setPen(discol);
}
- int xm = QWindowsStylePrivate::windowsItemFrame + checkcol + QWindowsStylePrivate::windowsItemHMargin;
+ int xm = int(QWindowsStylePrivate::windowsItemFrame) + checkcol + int(QWindowsStylePrivate::windowsItemHMargin);
int xpos = menuitem->rect.x() + xm;
QRect textRect(xpos, y + QWindowsStylePrivate::windowsItemVMargin,
w - xm - QWindowsStylePrivate::windowsRightBorder - tab + 1, h - 2 * QWindowsStylePrivate::windowsItemVMargin);
@@ -3223,7 +3223,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
w += checkcol;
- w += QWindowsStylePrivate::windowsRightBorder + 10;
+ w += int(QWindowsStylePrivate::windowsRightBorder) + 10;
sz.setWidth(w);
}
break;
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp
index 3b2e4e9..a7aa2ce 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/gui/text/qfontdatabase_x11.cpp
@@ -78,6 +78,9 @@ QT_BEGIN_NAMESPACE
extern double qt_pointSize(double pixelSize, int dpi);
extern double qt_pixelSize(double pointSize, int dpi);
+// from qapplication.cpp
+extern bool qt_is_gui_used;
+
static inline void capitalize (char *s)
{
bool space = true;
@@ -1938,7 +1941,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
} else if (X11->has_fontconfig) {
fe = loadFc(d, script, req);
- if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize) {
+ if (fe != 0 && fe->fontDef.pixelSize != req.pixelSize && mainThread && qt_is_gui_used) {
QFontEngine *xlfdFontEngine = loadXlfd(d->screen, script, req);
if (xlfdFontEngine->fontDef.family == fe->fontDef.family) {
delete fe;
@@ -1950,7 +1953,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
#endif
- } else if (mainThread) {
+ } else if (mainThread && qt_is_gui_used) {
fe = loadXlfd(d->screen, script, req);
}
if (!fe) {
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index f84059d..7941c4e 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -983,19 +983,9 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
return false;
}
-class ExceptionGuard
-{
-public:
- inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; }
- inline ~ExceptionGuard() { *watched = false; }
- inline operator bool() { return *watched; }
-private:
- bool *watched;
-};
-
void QMenuPrivate::activateCausedStack(const QList<QPointer<QWidget> > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self)
{
- ExceptionGuard guard(&activationRecursionGuard);
+ QBoolBlocker guard(activationRecursionGuard);
#ifdef QT3_SUPPORT
const int actionId = q_func()->findIdForAction(action);
#endif
diff --git a/tests/auto/qchar/tst_qchar.cpp b/tests/auto/qchar/tst_qchar.cpp
index 5ca2255..93aaf96 100644
--- a/tests/auto/qchar/tst_qchar.cpp
+++ b/tests/auto/qchar/tst_qchar.cpp
@@ -43,6 +43,7 @@
#include <QtTest/QtTest>
#include <qchar.h>
#include <qfile.h>
+#include <qstringlist.h>
#include <private/qunicodetables_p.h>
#if defined(Q_OS_WINCE)
#include <qcoreapplication.h>
@@ -75,6 +76,7 @@ private slots:
void isPrint();
void isUpper();
void isLower();
+ void isTitle();
void category();
void direction();
void joining();
@@ -83,7 +85,9 @@ private slots:
void decomposition();
// void ligature();
void lineBreakClass();
+ void normalization_data();
void normalization();
+ void normalization_manual();
void normalizationCorrections();
void unicodeVersion();
#if defined(Q_OS_WINCE)
@@ -234,6 +238,11 @@ void tst_QChar::isUpper()
QVERIFY(!QChar('?').isUpper());
QVERIFY(QChar(0xC2).isUpper()); // A with ^
QVERIFY(!QChar(0xE2).isUpper()); // a with ^
+
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Uppercase)
+ QVERIFY(codepoint == QChar::toUpper(codepoint));
+ }
}
void tst_QChar::isLower()
@@ -245,6 +254,19 @@ void tst_QChar::isLower()
QVERIFY(!QChar('?').isLower());
QVERIFY(!QChar(0xC2).isLower()); // A with ^
QVERIFY(QChar(0xE2).isLower()); // a with ^
+
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Lowercase)
+ QVERIFY(codepoint == QChar::toLower(codepoint));
+ }
+}
+
+void tst_QChar::isTitle()
+{
+ for (uint codepoint = 0; codepoint <= UNICODE_LAST_CODEPOINT; ++codepoint) {
+ if (QChar::category(codepoint) == QChar::Letter_Titlecase)
+ QVERIFY(codepoint == QChar::toTitleCase(codepoint));
+ }
}
void tst_QChar::category()
@@ -486,31 +508,13 @@ void tst_QChar::lineBreakClass()
QVERIFY(QUnicodeTables::lineBreakClass(0x0fffdu) == QUnicodeTables::LineBreak_AL);
}
-void tst_QChar::normalization()
+void tst_QChar::normalization_data()
{
- {
- QString composed;
- composed += QChar(0xc0);
- QString decomposed;
- decomposed += QChar(0x41);
- decomposed += QChar(0x300);
+ QTest::addColumn<QStringList>("columns");
+ QTest::addColumn<int>("part");
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
- }
- {
- QString composed;
- composed += QChar(0xa0);
- QString decomposed;
- decomposed += QChar(0x20);
-
- QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
- QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
- }
+ int linenum = 0;
+ int part = 0;
QFile f(SRCDIR "NormalizationTest.txt");
QVERIFY(f.exists());
@@ -518,6 +522,8 @@ void tst_QChar::normalization()
f.open(QIODevice::ReadOnly);
while (!f.atEnd()) {
+ linenum++;
+
QByteArray line;
line.resize(1024);
int len = f.readLine(line.data(), 1024);
@@ -527,8 +533,11 @@ void tst_QChar::normalization()
if (comment >= 0)
line = line.left(comment);
- if (line.startsWith("@"))
+ if (line.startsWith("@")) {
+ if (line.startsWith("@Part") && line.size() > 5 && QChar(line.at(5)).isDigit())
+ part = QChar(line.at(5)).digitValue();
continue;
+ }
if (line.isEmpty())
continue;
@@ -541,8 +550,10 @@ void tst_QChar::normalization()
Q_ASSERT(l.size() == 5);
- QString columns[5];
+ QStringList columns;
for (int i = 0; i < 5; ++i) {
+ columns.append(QString());
+
QList<QByteArray> c = l.at(i).split(' ');
Q_ASSERT(!c.isEmpty());
@@ -553,15 +564,26 @@ void tst_QChar::normalization()
columns[i].append(QChar(uc));
else {
// convert to utf16
- uc -= 0x10000;
- ushort high = uc/0x400 + 0xd800;
- ushort low = uc%0x400 + 0xdc00;
+ ushort high = QChar::highSurrogate(uc);
+ ushort low = QChar::lowSurrogate(uc);
columns[i].append(QChar(high));
columns[i].append(QChar(low));
}
}
}
+ QString nm = QString("line #%1:").arg(linenum);
+ QTest::newRow(nm.toLatin1()) << columns << part;
+ }
+}
+
+void tst_QChar::normalization()
+{
+ QFETCH(QStringList, columns);
+ QFETCH(int, part);
+
+ Q_UNUSED(part)
+
// CONFORMANCE:
// 1. The following invariants must be true for all conformant implementations
//
@@ -611,6 +633,32 @@ void tst_QChar::normalization()
// #################
+}
+
+void tst_QChar::normalization_manual()
+{
+ {
+ QString composed;
+ composed += QChar(0xc0);
+ QString decomposed;
+ decomposed += QChar(0x41);
+ decomposed += QChar(0x300);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == composed);
+ }
+ {
+ QString composed;
+ composed += QChar(0xa0);
+ QString decomposed;
+ decomposed += QChar(0x20);
+
+ QVERIFY(composed.normalized(QString::NormalizationForm_D) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_C) == composed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KD) == decomposed);
+ QVERIFY(composed.normalized(QString::NormalizationForm_KC) == decomposed);
}
}
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 3b2a716..9858829 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1536,6 +1536,43 @@ public:
inline void reset() { QStandardItemModel::reset(); }
};
+class ResetObserver : public QObject
+{
+ QItemSelectionModel * const m_selectionModel;
+ QItemSelection m_selection;
+ Q_OBJECT
+public:
+ ResetObserver(QItemSelectionModel *selectionModel)
+ : m_selectionModel(selectionModel)
+ {
+ connect(selectionModel->model(), SIGNAL(modelAboutToBeReset()),SLOT(modelAboutToBeReset()));
+ connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged(QItemSelection,QItemSelection)));
+ connect(selectionModel->model(), SIGNAL(modelReset()),SLOT(modelReset()));
+ }
+
+private slots:
+ void modelAboutToBeReset()
+ {
+ m_selection = m_selectionModel->selection();
+ foreach(const QItemSelectionRange &range, m_selection)
+ {
+ QVERIFY(range.isValid());
+ }
+ }
+
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
+ {
+ qDebug() << deselected << selected;
+ QCOMPARE(m_selection, deselected);
+ m_selection.clear();
+ }
+
+ void modelReset()
+ {
+ QVERIFY(m_selectionModel->selection().isEmpty());
+ }
+};
+
void tst_QItemSelectionModel::resetModel()
{
MyStandardItemModel model(20, 20);
@@ -1555,11 +1592,13 @@ void tst_QItemSelectionModel::resetModel()
view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
- QCOMPARE(spy.count(), 2);
- QCOMPARE(spy.at(1).count(), 2);
+ // We get this signal three times. Twice in this test method and once because the source reset causes the current selection to
+ // be deselected.
+ QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.at(2).count(), 2);
// make sure we don't get an "old selection"
- QCOMPARE(spy.at(1).at(1).userType(), qMetaTypeId<QItemSelection>());
- QVERIFY(qvariant_cast<QItemSelection>(spy.at(1).at(1)).isEmpty());
+ QCOMPARE(spy.at(2).at(1).userType(), qMetaTypeId<QItemSelection>());
+ QVERIFY(qvariant_cast<QItemSelection>(spy.at(2).at(1)).isEmpty());
}
void tst_QItemSelectionModel::removeRows_data()
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index e10d7ee..b6bdb36 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -51,6 +51,7 @@
#include <QListWidget>
#include <QWidgetAction>
#include <QDesktopWidget>
+#include <qdialog.h>
#include <qmenu.h>
#include <qstyle.h>
@@ -106,6 +107,7 @@ private slots:
void pushButtonPopulateOnAboutToShow();
void QTBUG7907_submenus_autoselect();
void QTBUG7411_submenus_activate();
+ void QTBUG_10735_crashWithDialog();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -969,5 +971,57 @@ void tst_QMenu::QTBUG7411_submenus_activate()
+class MyMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ MyMenu() : m_currentIndex(0)
+ {
+ for (int i = 0; i < 2; ++i)
+ dialogActions[i] = addAction( QString("dialog %1").arg(i), dialogs + i, SLOT(exec()));
+ }
+
+
+ void activateAction(int index)
+ {
+ m_currentIndex = index;
+ popup(QPoint());
+ QTest::qWaitForWindowShown(this);
+ setActiveAction(dialogActions[index]);
+ QTimer::singleShot(500, this, SLOT(checkVisibility()));
+ QTest::keyClick(this, Qt::Key_Enter); //activation
+ }
+
+public slots:
+ void activateLastAction()
+ {
+ activateAction(1);
+ }
+
+ void checkVisibility()
+ {
+ QTRY_VERIFY(dialogs[m_currentIndex].isVisible());
+ if (m_currentIndex == 1) {
+ QApplication::closeAllWindows(); //this is the end of the test
+ }
+ }
+
+
+private:
+ QAction *dialogActions[2];
+ QDialog dialogs[2];
+ int m_currentIndex;
+};
+
+void tst_QMenu::QTBUG_10735_crashWithDialog()
+{
+ MyMenu menu;
+
+ QTimer::singleShot(1000, &menu, SLOT(activateLastAction()));
+ menu.activateAction(0);
+
+}
+
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"