From 320e003d2ee71b8c58e930dabf0603f6dc1b1647 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Mon, 8 Jun 2009 15:15:56 +0300 Subject: Fix to qplaintextedit::getSetCheck auto test in Symbian. We cannot use INT_MAX since qreal is typedef to float in Symbian OS. --- tests/auto/qplaintextedit/tst_qplaintextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp index 6835c21..456ab7b 100644 --- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp @@ -221,7 +221,7 @@ void tst_QPlainTextEdit::getSetCheck() QCOMPARE(0, obj1.tabStopWidth()); obj1.setTabStopWidth(INT_MIN); QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value -#if defined(QT_ARCH_WINDOWSCE) +#if defined(QT_ARCH_WINDOWSCE) || defined (QT_ARCH_SYMBIAN) // due to rounding error in qRound when qreal==float // we cannot use INT_MAX for this check obj1.setTabStopWidth(SHRT_MAX*2); -- cgit v0.12 From 3e5b3a45a23d50732b3fcd5c44ab824d32deb1d8 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 8 Jun 2009 14:16:29 +0200 Subject: pointSize = 7 seems to be a good desfault for S60 There were no objections from the field with ing one Year of Tech Previews. --- src/gui/text/qfont.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 930e8af..dd50d12 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -796,7 +796,6 @@ QFont::QFont(const QString &family, int pointSize, int weight, bool italic) if (pointSize <= 0) { #ifdef Q_WS_S60 - // TODO: What should the default QFont pointSize for Q_WS_S60 be? pointSize = 7; #else pointSize = 12; -- cgit v0.12 From 40e305dee4d93a445721cfec37d00cb7f4f3fc0e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 8 Jun 2009 18:16:16 +0200 Subject: Removal of inneccessary QS60StylePrivate scopes --- src/gui/styles/qs60style.cpp | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6d24d54..971ba90 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -318,8 +318,8 @@ QVariant QS60StylePrivate::styleProperty(const char *name) const if (name == propertyKeyLayouts) { static QStringList layouts; if (layouts.isEmpty()) - for (int i = 0; i < QS60StylePrivate::m_numberOfLayouts; i++) - layouts.append(QS60StylePrivate::m_layoutHeaders[i].layoutName); + for (int i = 0; i < m_numberOfLayouts; i++) + layouts.append(m_layoutHeaders[i].layoutName); return layouts; } return QVariant(); @@ -388,7 +388,7 @@ QFont QS60StylePrivate::s60Font( return result; } -void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) +void QS60StylePrivate::clearCaches(CacheClearReason reason) { switch(reason){ case CC_LayoutChange: @@ -416,12 +416,12 @@ void QS60StylePrivate::clearCaches(QS60StylePrivate::CacheClearReason reason) // for QPalette::Button and QPalette::ToolTipBase. Therefore S60Style needs to guesstimate // palette colors by calculating average rgb values for button pixels. // Returns Qt::black if there is an issue with the graphics (image is NULL, or no bits() found). -QColor QS60StylePrivate::colorFromFrameGraphics(QS60StylePrivate::SkinFrameElements frame) const +QColor QS60StylePrivate::colorFromFrameGraphics(SkinFrameElements frame) const { const bool cachedColorExists = m_colorCache.contains(frame); if (!cachedColorExists) { - const int frameCornerWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); - const int frameCornerHeight = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerHeight); + const int frameCornerWidth = pixelMetric(PM_Custom_FrameCornerWidth); + const int frameCornerHeight = pixelMetric(PM_Custom_FrameCornerHeight); Q_ASSERT(2*frameCornerWidth<32); Q_ASSERT(2*frameCornerHeight<32); @@ -495,15 +495,15 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const { Q_UNUSED(app) QPalette applicationPalette = QApplication::palette(); - applicationPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); + applicationPalette.setBrush(QPalette::Window, backgroundTexture()); QApplication::setPalette(applicationPalette); } void QS60StylePrivate::deleteBackground() { - if (QS60StylePrivate::m_background) { - delete QS60StylePrivate::m_background; - QS60StylePrivate::m_background = 0; + if (m_background) { + delete m_background; + m_background = 0; } } @@ -670,7 +670,7 @@ void QS60StylePrivate::setThemePalette(QWidget *widget) const //draw transparent theme graphics to table column and row headers. if (qobject_cast(widget)){ widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); QHeaderView* header = qobject_cast(widget); widgetPalette.setColor(QPalette::Button, Qt::transparent ); if ( header->viewport() ) @@ -686,30 +686,30 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const // basic colors palette->setColor(QPalette::WindowText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); palette->setColor(QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); palette->setColor(QPalette::Text, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); palette->setColor(QPalette::ToolTipText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 55, 0)); palette->setColor(QPalette::BrightText, palette->color(QPalette::WindowText).lighter()); palette->setColor(QPalette::HighlightedText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 10, 0)); palette->setColor(QPalette::Link, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); + s60Color(QS60StyleEnums::CL_QsnHighlightColors, 3, 0)); palette->setColor(QPalette::LinkVisited, palette->color(QPalette::Link).darker()); palette->setColor(QPalette::Highlight, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); + s60Color(QS60StyleEnums::CL_QsnHighlightColors, 2, 0)); // set background image as a texture brush - palette->setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); + palette->setBrush(QPalette::Window, backgroundTexture()); // set these as transparent so that styled full screen theme background is visible palette->setColor(QPalette::AlternateBase, Qt::transparent); palette->setBrush(QPalette::Base, Qt::transparent); // set button and tooltipbase based on pixel colors - const QColor buttonColor = this->colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); + const QColor buttonColor = this->colorFromFrameGraphics(SF_ButtonNormal); palette->setColor(QPalette::Button, buttonColor ); - const QColor toolTipColor = this->colorFromFrameGraphics(QS60StylePrivate::SF_ToolTip); + const QColor toolTipColor = this->colorFromFrameGraphics(SF_ToolTip); palette->setColor(QPalette::ToolTipBase, toolTipColor ); palette->setColor(QPalette::Light, palette->color(QPalette::Button).lighter()); palette->setColor(QPalette::Dark, palette->color(QPalette::Button).darker()); @@ -718,7 +718,7 @@ void QS60StylePrivate::setThemePalette(QPalette *palette) const palette->setColor(QPalette::Shadow, Qt::black); setThemePaletteHash(palette); - QS60StylePrivate::storeThemePalette(palette); + storeThemePalette(palette); } void QS60StylePrivate::deleteThemePalette() @@ -745,10 +745,10 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const //store the original palette QPalette widgetPalette = *palette; const QColor mainAreaTextColor = - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); + s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0); widgetPalette.setColor(QPalette::All, QPalette::WindowText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); + s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0)); QApplication::setPalette(widgetPalette, "QSlider"); // return to original palette after each widget widgetPalette = *palette; @@ -757,7 +757,7 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const widgetPalette.setColor(QPalette::Inactive, QPalette::ButtonText, mainAreaTextColor); const QStyleOption opt; widgetPalette.setColor(QPalette::Disabled, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 6, &opt)); QApplication::setPalette(widgetPalette, "QPushButton"); widgetPalette = *palette; @@ -767,27 +767,27 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const widgetPalette = *palette; widgetPalette.setColor(QPalette::Active, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 23, 0)); QApplication::setPalette(widgetPalette, "QHeaderView"); widgetPalette = *palette; widgetPalette.setColor(QPalette::All, QPalette::ButtonText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0)); QApplication::setPalette(widgetPalette, "QMenuBar"); widgetPalette = *palette; widgetPalette.setColor(QPalette::Active, QPalette::WindowText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0)); QApplication::setPalette(widgetPalette, "QTabBar"); widgetPalette = *palette; widgetPalette.setColor(QPalette::All, QPalette::Text, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0)); QApplication::setPalette(widgetPalette, "QTableView"); widgetPalette = *palette; widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, - QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); + s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); widgetPalette = *palette; @@ -861,7 +861,7 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag } break; } - if (flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest)) { + if (flags & (SF_PointEast | SF_PointWest)) { const int temp = result.width(); result.setWidth(result.height()); result.setHeight(temp); -- cgit v0.12 From 806e0081bf8c77d990e4b0fafdec93f07bdcbfab Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 8 Jun 2009 18:17:10 +0200 Subject: Attempt to load default skin only if it is present. --- src/gui/styles/qs60style_simulated.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index a94d73e..7667f92 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -359,7 +359,9 @@ QS60Style::QS60Style() : QCommonStyle(*new QS60StylePrivate) { // Assume, that the resource system has a ':/s60Stylethemes/Default.blob' - loadS60ThemeFromBlob(QString::fromLatin1(":/s60Stylethemes/Default.blob")); + const QString defaultBlob = QString::fromLatin1(":/s60Stylethemes/Default.blob"); + if (QFile::exists(defaultBlob)) + loadS60ThemeFromBlob(defaultBlob); } Q_GLOBAL_STATIC_WITH_INITIALIZER(QStringList, enumPartKeys, { -- cgit v0.12 From b84811da86a7c3c9be153a2c4f9a52a759bc70d0 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 8 Jun 2009 18:17:54 +0200 Subject: More usable output of the s60theme utility --- util/s60theme/s60theme.pro | 3 +++ util/s60theme/s60themeconvert.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/util/s60theme/s60theme.pro b/util/s60theme/s60theme.pro index 02c2449..83c0cf2 100644 --- a/util/s60theme/s60theme.pro +++ b/util/s60theme/s60theme.pro @@ -7,3 +7,6 @@ HEADERS += \ QT += \ webkit + +CONFIG += \ + console diff --git a/util/s60theme/s60themeconvert.cpp b/util/s60theme/s60themeconvert.cpp index 4fe2980..a1e1d58 100644 --- a/util/s60theme/s60themeconvert.cpp +++ b/util/s60theme/s60themeconvert.cpp @@ -206,7 +206,7 @@ bool loadThemeFromTdf(const QString &tdfFile, const QString tdfFullName = tdfBasePath + QDir::separator() + parsedPartSvgs.value(partKey); if (!QFile(tdfFullName).exists()) - qWarning() << "Could not load part " << tdfFullName; + qWarning() << "Could not find part:" << parsedPartSvgs.value(partKey); const QPicture partPicture = renderer.svgToQPicture(tdfFullName); parsedPartPictures.insert(partKey, partPicture); } @@ -273,9 +273,10 @@ bool loadDefaultTheme(const QString &themePath, WebKitSVGRenderer renderer; foreach (const QString &partKey, QS60Style::partKeys()) { - const QString partFile(dir.absolutePath() + QDir::separator() + partKey + QLatin1String(".svg")); + const QString partFileName = partKey + QLatin1String(".svg"); + const QString partFile(dir.absolutePath() + QDir::separator() + partFileName); if (!QFile::exists(partFile)) { - qWarning() << "Could not load part " << partFile; + qWarning() << "Could not find part:" << partFileName; continue; } const QPicture partPicture = renderer.svgToQPicture(partFile); -- cgit v0.12 From 846c49cd1c0730143888a1deb0ab32811583014f Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 9 Jun 2009 13:37:09 +0300 Subject: Fixed STL dependency for Symbian. The STL config is stored in CONFIG qmake variable, not in QT_CONFIG. --- src/s60installs/qt_libs.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/qt_libs.pro b/src/s60installs/qt_libs.pro index 9aadfc0..e9da90d 100644 --- a/src/s60installs/qt_libs.pro +++ b/src/s60installs/qt_libs.pro @@ -41,7 +41,7 @@ symbian: { contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { qtlibraries.depends += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}" } - contains(QT_CONFIG, stl) { + contains(CONFIG, stl) { qtlibraries.depends += "(0x2000F866), 1, 0, 0, {\"Standard C++ Library Common\"}" } -- cgit v0.12 From 3b4a2650064e1333684d2b2d2c3923d0b798ed82 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 9 Jun 2009 17:50:13 +0200 Subject: Itemviews have go their focus frame back. Got lost with dc177883bf98a68e61c9a9cda7e1ba9464079275 --- src/gui/styles/qs60style.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 971ba90..180937f 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1880,11 +1880,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } break; #endif //QT_NO_TOOLBAR - case CE_ShapedFrame: { - const QTextEdit *txt = qobject_cast(widget); - if (txt) + case CE_ShapedFrame: + if (qobject_cast(widget)) QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); - } + if (option->state & State_HasFocus) + drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; default: QCommonStyle::drawControl(element, option, painter, widget); -- cgit v0.12 From dcaa6ab545e7532b5455734bd8d234cb76b152fa Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Wed, 10 Jun 2009 09:29:19 +0300 Subject: Enabled default iap setting for FTP example. This should remove multiple IAP queries when using FTP example. The used IAP is now asked from user when application is started. --- examples/network/ftp/ftp.pro | 4 +--- examples/network/ftp/main.cpp | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/examples/network/ftp/ftp.pro b/examples/network/ftp/ftp.pro index 90594f5..b958f6a 100644 --- a/examples/network/ftp/ftp.pro +++ b/examples/network/ftp/ftp.pro @@ -13,9 +13,7 @@ INSTALLS += target sources include($$QT_SOURCE_TREE/examples/examplebase.pri) symbian { - #Enable this macro if you have latest Open C and you want to get rid of IAP queries - #DEFINES += SETDEFAULTIF_AVAILABLE TARGET.CAPABILITY="NetworkServices" TARGET.UID3 = 0xA000A648 - contains( DEFINES, SETDEFAULTIF_AVAILABLE ):LIBS+=-lesock + LIBS+=-lesock # For IAP selection } \ No newline at end of file diff --git a/examples/network/ftp/main.cpp b/examples/network/ftp/main.cpp index a472fd7..a92a8b2 100644 --- a/examples/network/ftp/main.cpp +++ b/examples/network/ftp/main.cpp @@ -40,13 +40,12 @@ ****************************************************************************/ #include +#include "ftpwindow.h" + #ifdef Q_OS_SYMBIAN #include #include -#endif -#include "ftpwindow.h" -#if defined Q_OS_SYMBIAN && defined SETDEFAULTIF_AVAILABLE #include #include #include @@ -66,13 +65,15 @@ static void setDefaultIapL() _LIT(KIapNameSetting, "IAP\\Name"); TBuf8<50> iapName; User::LeaveIfError(conn.GetDesSetting(TPtrC(KIapNameSetting), iapName)); + iapName.ZeroTerminate(); + + conn.Stop(); + CleanupStack::PopAndDestroy(&conn); + CleanupStack::PopAndDestroy(&serv); - struct ifreq ifReq; + struct ifreq ifReq; strcpy( ifReq.ifr_name, (char*)iapName.Ptr()); User::LeaveIfError(setdefaultif( &ifReq )); - - CleanupStack::PopAndDestroy(&conn); - CleanupStack::PopAndDestroy(&serv); } static int setDefaultIap() @@ -80,7 +81,6 @@ static int setDefaultIap() TRAPD(err, setDefaultIapL()); return err; } - #endif int main(int argc, char *argv[]) @@ -88,9 +88,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(ftp); #ifdef Q_OS_SYMBIAN -#ifdef SETDEFAULTIF_AVAILABLE - setDefaultIap(); -#endif + setDefaultIap(); // Change current directory from default private to c:\data // in order that user can access the downloaded content QDir::setCurrent( "c:\\data" ); @@ -100,7 +98,8 @@ int main(int argc, char *argv[]) #ifdef Q_OS_SYMBIAN // Make application better looking and more usable on small screen ftpWin.showMaximized(); -#endif +#else ftpWin.show(); +#endif return ftpWin.exec(); } -- cgit v0.12 From b97671a3b40623c1499c13c3d74c896ac6b9406f Mon Sep 17 00:00:00 2001 From: makuukka Date: Fri, 29 May 2009 10:08:27 +0300 Subject: Force qRound64() to take a double on platforms where qreal is a float. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Symbian qreal is defined as float. And in qround64 the parameter was qreal. This qround64 is used (only) in qvariant::convert, when converting from double to e.g. int. This caused overflow bug for some (close to max int) values, because in convert chain double value was casted to float. Task-number: 250267 Reviewed-By: Samuel Rødal Reviewed-By: Jason Barron --- src/corelib/global/qglobal.h | 5 +++++ tests/auto/qvariant/tst_qvariant.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 27aaac1..b075db6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1055,8 +1055,13 @@ inline T qAbs(const T &t) { return t >= 0 ? t : -t; } inline int qRound(qreal d) { return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); } +#if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) +inline qint64 qRound64(double d) +{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); } +#else inline qint64 qRound64(qreal d) { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qint64(d-1) + 0.5) + qint64(d-1); } +#endif template inline const T &qMin(const T &a, const T &b) { if (a < b) return a; return b; } diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp index d15f9c8..9c9ff33 100644 --- a/tests/auto/qvariant/tst_qvariant.cpp +++ b/tests/auto/qvariant/tst_qvariant.cpp @@ -255,6 +255,7 @@ private slots: void convertByteArrayToBool() const; void convertByteArrayToBool_data() const; void toIntFromQString() const; + void toIntFromDouble() const; }; Q_DECLARE_METATYPE(QDate) @@ -2909,5 +2910,30 @@ void tst_QVariant::toIntFromQString() const QVERIFY(ok); } +/*! + We verify that: + 1. Conversion from (64 bit) double to int works (no overflow). + 2. Same conversion works for QVariant::convert. + + Rationale: if 2147483630 is set in float and then converted to int, + there will be overflow and the result will be -2147483648. + + See task 250267. + */ +void tst_QVariant::toIntFromDouble() const +{ + double d = 2147483630; // max int 2147483647 + QVERIFY((int)d == 2147483630); + + QVariant var(d); + QVERIFY( var.canConvert( QVariant::Int ) ); + + bool ok; + int result = var.toInt(&ok); + + QVERIFY( ok == true ); + QCOMPARE(result, 2147483630); +} + QTEST_MAIN(tst_QVariant) #include "tst_qvariant.moc" -- cgit v0.12