From 0650ec9effe5d9dd643d1bc19d2af591244671d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 10 Aug 2010 15:03:12 +0200 Subject: Fix documentation for QAccessible::InterfaceFactory Reported to me by Martin P. --- .../snippets/code/src_gui_accessible_qaccessible.cpp | 4 ++++ src/gui/accessible/qaccessible.cpp | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp index 8434d81..c5ca441 100644 --- a/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp +++ b/doc/src/snippets/code/src_gui_accessible_qaccessible.cpp @@ -46,3 +46,7 @@ if (child) { delete child; } //! [0] + +//! [1] +typedef QAccessibleInterface* myFactoryFunction(const QString &key, QObject *); +//! [1] \ No newline at end of file diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 0921bdb..a6d1dbd 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -409,13 +409,18 @@ static void qAccessibleCleanup() /*! \typedef QAccessible::InterfaceFactory - A function pointer type. Use a function with this prototype to install - interface factories with installFactory(). + This is a typedef for a pointer to a function with the following + signature: - The function receives a QObject pointer. If the QObject - provides a QAccessibleInterface, it sets the second parameter to - point to the corresponding QAccessibleInterface, and returns true; - otherwise returns false. + \snippet doc/src/snippets/code/src_gui_accessible_qaccessible.cpp 1 + + The function receives a QString and a QObject pointer, where the + QString is the key identifying the interface. The QObject is used + to pass on to the QAccessibleInterface so that it can hold a reference + to it. + + If the key and the QObject does not have a corresponding + QAccessibleInterface, a null-pointer will be returned. Installed factories are called by queryAccessibilityInterface() until one provides an interface. -- cgit v0.12 From dd2a5c1556cf29fac03ae789dd5c43f482011d68 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 28 Jul 2010 12:40:30 +0200 Subject: Fix compilation on 64-bit Windows. When compiling for 64-bit with Visual Studio 2008, inline assembly is not supported. Use intrisic instead. Reviewed-by: Benjamin Poulain --- src/corelib/tools/qsimd.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp index 5aa7217..8005d7d 100644 --- a/src/corelib/tools/qsimd.cpp +++ b/src/corelib/tools/qsimd.cpp @@ -46,6 +46,10 @@ #include #endif +#if defined(Q_OS_WIN64) && !defined(Q_CC_GNU) +#include +#endif + QT_BEGIN_NAMESPACE uint qDetectCPUFeatures() @@ -261,31 +265,10 @@ uint qDetectCPUFeatures() : "%eax", "%ecx", "%edx" ); #elif defined (Q_OS_WIN64) - _asm { - push rax - push rbx - push rcx - push rdx - pushfd - pop rax - mov ebx, eax - xor eax, 00200000h - push rax - popfd - pushfd - pop rax - mov edx, 0 - xor eax, ebx - jz skip - - mov eax, 1 - cpuid - mov feature_result, ecx - skip: - pop rdx - pop rcx - pop rbx - pop rax + { + int info[4]; + __cpuid(info, 1); + feature_result = info[2]; } #endif -- cgit v0.12 From 99fd5825dfb4d50cff93165995701a65b7a8e4ed Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Tue, 10 Aug 2010 15:58:25 +0200 Subject: Make selection work across ligatures For widgets like QPlainTextEdit, selection across ligatures (typically 'fi', 'ffi', 'fl', etc.) end up highlighting the entire ligature glyphs, this patch fixed that by dividing width inside the ligature so that selection will not expand past the actual selected characters. Since cursor position already considered this, we merely adopted the algorithm and made it a separated helper function for all necessary cases. Dividing width directly looks like a temporary workaround but works well enough so far for cursor positions. Task-number: QTBUG-11969 Reviewed-by: Eskil --- src/gui/text/qtextlayout.cpp | 64 +++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 531e46b..9d27343 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1035,6 +1035,35 @@ QScriptItem &QTextLineItemIterator::next() return *si; } +static QFixed offsetInLigature(const unsigned short *logClusters, + const QGlyphLayout &glyphs, + int pos, int max, int glyph_pos) +{ + int offsetInCluster = 0; + for (int i = pos - 1; i >= 0; i--) { + if (logClusters[i] == glyph_pos) + offsetInCluster++; + else + break; + } + + // in the case that the offset is inside a (multi-character) glyph, + // interpolate the position. + if (offsetInCluster > 0) { + int clusterLength = 0; + for (int i = pos - offsetInCluster; i < max; i++) { + if (logClusters[i] == glyph_pos) + clusterLength++; + else + break; + } + if (clusterLength) + return glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength; + } + + return 0; +} + bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selectionWidth) const { *selectionX = *selectionWidth = 0; @@ -1074,8 +1103,19 @@ bool QTextLineItemIterator::getSelectionBounds(QFixed *selectionX, QFixed *selec swidth += glyphs.effectiveAdvance(g); } - *selectionX = x + soff; - *selectionWidth = swidth; + // If the starting character is in the middle of a ligature, + // selection should only contain the right part of that ligature + // glyph, so we need to get the width of the left part here and + // add it to *selectionX + QFixed leftOffsetInLigature = offsetInLigature(logClusters, glyphs, from, + to, start_glyph); + *selectionX = x + soff + leftOffsetInLigature; + *selectionWidth = swidth - leftOffsetInLigature; + // If the ending character is also part of a ligature, swidth does + // not contain that part yet, we also need to find out the width of + // that left part + *selectionWidth += offsetInLigature(logClusters, glyphs, to, + eng->length(item), end_glyph); } return true; } @@ -2633,14 +2673,6 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const if(pos == l) x += si->width; } else { - int offsetInCluster = 0; - for (int i=pos-1; i >= 0; i--) { - if (logClusters[i] == glyph_pos) - offsetInCluster++; - else - break; - } - if (reverse) { int end = qMin(lineEnd, si->position + l) - si->position; int glyph_end = end == l ? si->num_glyphs : logClusters[end]; @@ -2652,17 +2684,7 @@ qreal QTextLine::cursorToX(int *cursorPos, Edge edge) const for (int i = glyph_start; i < glyph_pos; i++) x += glyphs.effectiveAdvance(i); } - if (offsetInCluster > 0) { // in the case that the offset is inside a (multi-character) glyph, interpolate the position. - int clusterLength = 0; - for (int i=pos - offsetInCluster; i < line.length; i++) { - if (logClusters[i] == glyph_pos) - clusterLength++; - else - break; - } - if (clusterLength) - x+= glyphs.advances_x[glyph_pos] * offsetInCluster / clusterLength; - } + x += offsetInLigature(logClusters, glyphs, pos, line.length, glyph_pos); } *cursorPos = pos + si->position; -- cgit v0.12 From ca8d92f1d30b1519ccbfdab44e3868e9556b3fb5 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 11:46:52 +0200 Subject: Optimize QSharedPointer::operator=(const QSharedPointer &) internalSet check that stringref is > 0 Which is not required as we do not assign from a QWeakPointer Reviewed-by: Thiago Task-number: QTBUG-12700 --- src/corelib/tools/qsharedpointer_impl.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index dd27f7e..7f0de5f 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -387,7 +387,13 @@ namespace QtSharedPointer { template inline void internalCopy(const ExternalRefCount &other) { - internalSet(other.d, other.data()); + Data *o = other.d; + T *actual = other.value; + if (o) + other.ref(); + qSwap(d, o); + qSwap(this->value, actual); + deref(o, actual); } inline void internalSwap(ExternalRefCount &other) -- cgit v0.12 From 4e626903d0f6df00fa83c18061a12cb3a5dbd603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 10 Aug 2010 16:53:18 +0200 Subject: Replace gluOrtho2d with glOrtho. GLU dependency was removed in commit: c67b4cac2e53ae77c4e16487838c17be85e73aa3, so instead of using gluOrtho2d we simply use glOrtho with near=-1 and far=1. --- src/3rdparty/phonon/qt7/videowidget.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/qt7/videowidget.mm b/src/3rdparty/phonon/qt7/videowidget.mm index 736dcdf..c281e16 100644 --- a/src/3rdparty/phonon/qt7/videowidget.mm +++ b/src/3rdparty/phonon/qt7/videowidget.mm @@ -278,7 +278,7 @@ public: glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, GLsizei(w), GLsizei(h)); - gluOrtho2D(0, GLsizei(w), 0, GLsizei(h)); + glOrtho(0, GLsizei(w), 0, GLsizei(h), -1, 1); updateGL(); } -- cgit v0.12 From 7a3e217f4dab6a47a00da34c22f950fc2a9d8a53 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 10 Aug 2010 15:53:10 +0200 Subject: qmake vcproj generator cleanup MSVCPROJ_CXXFLAGS removed. This was unused. MSVCPROJ_LFLAGS removed. This was used to convert the values of QMAKE_LFLAGS, QMAKE_LIBDIR and DEF_FILE to linker command line options. Then they were converted back to set values in the object model. This journey to the world of command line options isn't necessary... Reviewed-by: ossi --- qmake/generators/win32/msvc_vcproj.cpp | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 345bd3a..f32ba7e 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -996,7 +996,17 @@ void VcprojGenerator::initLinkerTool() { findLibraries(); // Need to add the highest version of the libs VCConfiguration &conf = vcProject.Configuration; - conf.linker.parseOptions(project->values("MSVCPROJ_LFLAGS")); + conf.linker.parseOptions(project->values("QMAKE_LFLAGS")); + + foreach (const QString &libDir, project->values("QMAKE_LIBDIR")) { + if (libDir.startsWith("/LIBPATH:")) + conf.linker.AdditionalLibraryDirectories += libDir.mid(9); + else + conf.linker.AdditionalLibraryDirectories += libDir; + } + + if (!project->values("DEF_FILE").isEmpty()) + conf.linker.ModuleDefinitionFile = project->first("DEF_FILE"); foreach(QString libs, project->values("MSVCPROJ_LIBS")) { if (libs.left(9).toUpper() == "/LIBPATH:") { @@ -1458,17 +1468,6 @@ void VcprojGenerator::initOld() // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS"); project->values("MSVCPROJ_LIBS") += project->values("QMAKE_LIBS_PRIVATE"); - project->values("MSVCPROJ_LFLAGS") += project->values("QMAKE_LFLAGS"); - if(!project->values("QMAKE_LIBDIR").isEmpty()) { - QStringList strl = project->values("QMAKE_LIBDIR"); - QStringList::iterator stri; - for(stri = strl.begin(); stri != strl.end(); ++stri) { - if(!(*stri).startsWith("/LIBPATH:")) - (*stri).prepend("/LIBPATH:"); - } - project->values("MSVCPROJ_LFLAGS") += strl; - } - project->values("MSVCPROJ_CXXFLAGS") += project->values("QMAKE_CXXFLAGS"); QStringList &incs = project->values("INCLUDEPATH"); for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { QString inc = (*incit); @@ -1507,9 +1506,6 @@ void VcprojGenerator::initOld() project->values("MSVCPROJ_COPY_DLL_DESC").append(deststr); } - if (!project->values("DEF_FILE").isEmpty()) - project->values("MSVCPROJ_LFLAGS").append("/DEF:"+project->first("DEF_FILE")); - project->values("QMAKE_INTERNAL_PRL_LIBS") << "MSVCPROJ_LIBS"; // Verbose output if "-d -d"... -- cgit v0.12 From 0c9866d6b23062bc08e739b66f41de200b660df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kimmo=20Kotaj=C3=A4rvi?= Date: Wed, 26 May 2010 14:53:23 +0200 Subject: Fix for QTBUG-2182: "connection still in use" warnings. --- src/sql/kernel/qsqldatabase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 76bc2b0..324a3ce 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -163,7 +163,7 @@ public: static QSqlDatabase database(const QString& name, bool open); static void addDatabase(const QSqlDatabase &db, const QString & name); static void removeDatabase(const QString& name); - static void invalidateDb(const QSqlDatabase &db, const QString &name); + static void invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn = true); static DriverDict &driverDict(); static void cleanConnections(); }; @@ -197,7 +197,7 @@ void QSqlDatabasePrivate::cleanConnections() QConnectionDict::iterator it = dict->begin(); while (it != dict->end()) { - invalidateDb(it.value(), it.key()); + invalidateDb(it.value(), it.key(), false); ++it; } dict->clear(); @@ -229,9 +229,9 @@ QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() return &n; } -void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name) +void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn) { - if (db.d->ref != 1) { + if (db.d->ref != 1 && doWarn) { qWarning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, " "all queries will cease to work.", name.toLocal8Bit().constData()); db.d->disable(); -- cgit v0.12 From 1023209b9c335d72dc489d67e632d80cadac924d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 11 Aug 2010 09:59:53 +0200 Subject: Fix build os QSharedPointer on MSVC Which does not support template friends Reviewed-by: Thiago --- src/corelib/tools/qsharedpointer_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 7f0de5f..bb06f3a 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -322,7 +322,6 @@ namespace QtSharedPointer { protected: typedef ExternalRefCountData Data; - inline void ref() const { d->weakref.ref(); d->strongref.ref(); } inline void deref() { deref(d, this->value); } static inline void deref(Data *d, T *value) @@ -409,6 +408,7 @@ namespace QtSharedPointer { template friend class QT_PREPEND_NAMESPACE(QWeakPointer); template friend QSharedPointer copyAndSetPointer(X * ptr, const QSharedPointer &src); #endif + inline void ref() const { d->weakref.ref(); d->strongref.ref(); } inline void internalSet(Data *o, T *actual) { -- cgit v0.12