summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-10-25 21:34:02 +1000
committerQt Continuous Integration System <qt-info@nokia.com>2011-10-25 21:34:02 +1000
commit9ff6bc28d5977bde97e8429328028e46572be445 (patch)
treec3ad9676560a01ee61810ad0710c2df8c67d431f /src/gui
parentcb4eb590d4af9978a0d60402f3c4ab99b6f4ede4 (diff)
parent50c09f63d31ba92b4035d47365e01f5fb65a9cc1 (diff)
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-water-staging: Fix bug in QStringToBSTR. Fix regression in ListView Fixed resource leak when setting QProgressBar style sheet Fix regression introduced by 1bfef526ef3d1deb7cf0f11dc1880f33937a85ac don't lock the global mutex if there is nothing to protect fix possible race conditions simplify the code by using QSystemLibrary a bit smarter use QSystemLibrary::resolve() instead of GetProcAddress() win API calls nativewifi bearer plugin: prefer DLL Safe Search mode make QElapsedTimer use QSystemLibrary on win QTBUG-21058: Fix for possible crashes in QTextControl::setCursorWidth() Fix bug in QGraphicsItem::isVisibleTo(). nano-opts, styling fixes don't assume the PATH envvar is latin1-encoded Set missing flags in the option when rendering QTreeView drag pixmap Fix typo when updating accessible treeview selection.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible_win.cpp11
-rw-r--r--src/gui/dialogs/qfiledialog_win.cpp30
-rw-r--r--src/gui/dialogs/qwizard_win.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp20
-rw-r--r--src/gui/image/qpixmap_mac.cpp4
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp1
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h2
-rw-r--r--src/gui/itemviews/qlistview.cpp8
-rw-r--r--src/gui/itemviews/qtableview.cpp2
-rw-r--r--src/gui/itemviews/qtreeview.cpp113
-rw-r--r--src/gui/itemviews/qtreeview_p.h5
-rw-r--r--src/gui/kernel/qapplication_win.cpp53
-rw-r--r--src/gui/kernel/qguifunctions_wince.cpp5
-rw-r--r--src/gui/kernel/qmime_mac.cpp4
-rw-r--r--src/gui/styles/qwindowsstyle.cpp3
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp2
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp2
-rw-r--r--src/gui/text/qfontengine_win.cpp5
-rw-r--r--src/gui/text/qtextcontrol.cpp8
-rw-r--r--src/gui/widgets/qmenu_wince.cpp2
20 files changed, 147 insertions, 135 deletions
diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp
index 1fd1bfd053..f404535517 100644
--- a/src/gui/accessible/qaccessible_win.cpp
+++ b/src/gui/accessible/qaccessible_win.cpp
@@ -353,8 +353,8 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason)
static PtrNotifyWinEvent ptrNotifyWinEvent = 0;
static bool resolvedNWE = false;
if (!resolvedNWE) {
- resolvedNWE = true;
ptrNotifyWinEvent = (PtrNotifyWinEvent)QSystemLibrary::resolve(QLatin1String("user32"), "NotifyWinEvent");
+ resolvedNWE = true;
}
if (!ptrNotifyWinEvent)
return;
@@ -691,14 +691,7 @@ private:
static inline BSTR QStringToBSTR(const QString &str)
{
- BSTR bstrVal;
-
- int wlen = str.length()+1;
- bstrVal = SysAllocStringByteLen(0, wlen*2);
- memcpy(bstrVal, str.unicode(), sizeof(QChar)*(wlen));
- bstrVal[wlen] = 0;
-
- return bstrVal;
+ return SysAllocStringLen((OLECHAR*)str.unicode(), str.length());
}
/*
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp
index 6691ff1472..2d4769afde 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/gui/dialogs/qfiledialog_win.cpp
@@ -55,10 +55,6 @@
#include <private/qsystemlibrary_p.h>
#include "qfiledialog_win_p.h"
-#ifndef QT_NO_THREAD
-# include <private/qmutexpool_p.h>
-#endif
-
#ifdef Q_WS_WINCE
#include <commdlg.h>
bool qt_priv_ptr_valid = false;
@@ -83,35 +79,23 @@ QT_BEGIN_NAMESPACE
static void qt_win_resolve_libs()
{
static bool triedResolve = false;
-
if (!triedResolve) {
-#ifndef QT_NO_THREAD
- // protect initialization
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- // check triedResolve again, since another thread may have already
- // done the initialization
- if (triedResolve) {
- // another thread did initialize the security function pointers,
- // so we shouldn't do it again.
- return;
- }
-#endif
-
- triedResolve = true;
#if !defined(Q_WS_WINCE)
- QSystemLibrary lib(L"shell32");
+ QSystemLibrary lib(QLatin1String("shell32"));
ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW");
ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDListW");
ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc");
#else
// CE stores them in a different lib and does not use unicode version
- HINSTANCE handle = LoadLibrary(L"Ceshell");
- ptrSHBrowseForFolder = (PtrSHBrowseForFolder)GetProcAddress(handle, L"SHBrowseForFolder");
- ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)GetProcAddress(handle, L"SHGetPathFromIDList");
- ptrSHGetMalloc = (PtrSHGetMalloc)GetProcAddress(handle, L"SHGetMalloc");
+ QSystemLibrary lib(QLatin1String("Ceshell"));
+ ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolder");
+ ptrSHGetPathFromIDList = (PtrSHGetPathFromIDList)lib.resolve("SHGetPathFromIDList");
+ ptrSHGetMalloc = (PtrSHGetMalloc)lib.resolve("SHGetMalloc");
if (ptrSHBrowseForFolder && ptrSHGetPathFromIDList && ptrSHGetMalloc)
qt_priv_ptr_valid = true;
#endif
+
+ triedResolve = true;
}
}
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
index 9ea114c63f..00ebbfdda1 100644
--- a/src/gui/dialogs/qwizard_win.cpp
+++ b/src/gui/dialogs/qwizard_win.cpp
@@ -705,7 +705,6 @@ bool QVistaHelper::resolveSymbols()
{
static bool tried = false;
if (!tried) {
- tried = true;
QSystemLibrary dwmLib(L"dwmapi");
pDwmIsCompositionEnabled =
(PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
@@ -727,6 +726,7 @@ bool QVistaHelper::resolveSymbols()
pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx");
pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute");
}
+ tried = true;
}
return (
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index cb7349ca97..73e8eed6e2 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2237,7 +2237,8 @@ bool QGraphicsItem::isVisible() const
returned. \a parent can be 0, in which case this function will return
whether the item is visible to the scene or not.
- An item may not be visible to its ancestors even if isVisible() is true. If
+ An item may not be visible to its ancestors even if isVisible() is true. It
+ may also be visible to its ancestors even if isVisible() is false. If
any ancestor is hidden, the item itself will be implicitly hidden, in which
case this function will return false.
@@ -2245,15 +2246,16 @@ bool QGraphicsItem::isVisible() const
*/
bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
{
- if (!d_ptr->visible)
+ const QGraphicsItem *p = this;
+ if (d_ptr->explicitlyHidden)
return false;
- if (parent == this)
- return true;
- if (parentItem() && parentItem()->isVisibleTo(parent))
- return true;
- if (!parent && !parentItem())
- return true;
- return false;
+ do {
+ if (p == parent)
+ return true;
+ if (p->d_ptr->explicitlyHidden)
+ return false;
+ } while ((p = p->d_ptr->parent));
+ return parent == 0;
}
/*!
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index 47b6eef761..aa1571bc6d 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -752,7 +752,8 @@ static PtrglReadPixels ptrglReadPixels = 0;
static bool resolveOpenGLSymbols()
{
- if (ptrCGLChoosePixelFormat == 0) {
+ static bool triedResolve = false;
+ if (!triedResolve) {
QLibrary library(QLatin1String("/System/Library/Frameworks/OpenGL.framework/OpenGL"));
ptrCGLChoosePixelFormat = (PtrCGLChoosePixelFormat)(library.resolve("CGLChoosePixelFormat"));
ptrCGLClearDrawable = (PtrCGLClearDrawable)(library.resolve("CGLClearDrawable"));
@@ -765,6 +766,7 @@ static bool resolveOpenGLSymbols()
ptrglPixelStorei = (PtrglPixelStorei)(library.resolve("glPixelStorei"));
ptrglReadBuffer = (PtrglReadBuffer)(library.resolve("glReadBuffer"));
ptrglReadPixels = (PtrglReadPixels)(library.resolve("glReadPixels"));
+ triedResolve = true;
}
return ptrCGLChoosePixelFormat && ptrCGLClearDrawable && ptrCGLCreateContext
&& ptrCGLDestroyContext && ptrCGLDestroyPixelFormat && ptrCGLSetCurrentContext
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index ded4d63bbe..1676c46bef 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -4238,6 +4238,7 @@ QPixmap QAbstractItemViewPrivate::renderToPixmap(const QModelIndexList &indexes,
for (int j = 0; j < paintPairs.count(); ++j) {
option.rect = paintPairs.at(j).first.translated(-r->topLeft());
const QModelIndex &current = paintPairs.at(j).second;
+ adjustViewOptionsForIndex(&option, current);
delegateForIndex(current)->paint(&painter, option, current);
}
return pixmap;
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
index 04babde9e2..b742529cf1 100644
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ b/src/gui/itemviews/qabstractitemview_p.h
@@ -193,6 +193,8 @@ public:
#endif
virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
+ // reimplemented in subclasses
+ virtual void adjustViewOptionsForIndex(QStyleOptionViewItemV4*, const QModelIndex&) const {}
inline void releaseEditor(QWidget *editor) const {
if (editor) {
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
index a0955d256e..01a9eec078 100644
--- a/src/gui/itemviews/qlistview.cpp
+++ b/src/gui/itemviews/qlistview.cpp
@@ -1475,7 +1475,7 @@ void QListView::doItemsLayout()
void QListView::updateGeometries()
{
Q_D(QListView);
- if (d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
+ if (geometry().isEmpty() || d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
horizontalScrollBar()->setRange(0, 0);
verticalScrollBar()->setRange(0, 0);
} else {
@@ -1490,15 +1490,15 @@ void QListView::updateGeometries()
// if the scroll bars are turned off, we resize the contents to the viewport
if (d->movement == Static && !d->isWrapping()) {
- const QSize maxSize = maximumViewportSize();
+ d->layoutChildren(); // we need the viewport size to be updated
if (d->flow == TopToBottom) {
if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(maxSize.width(), contentsSize().height());
+ d->setContentsSize(viewport()->width(), contentsSize().height());
horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway
}
} else { // LeftToRight
if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(contentsSize().width(), maxSize.height());
+ d->setContentsSize(contentsSize().width(), viewport()->height());
verticalScrollBar()->setRange(0, 0); // we see all the contents anyway
}
}
diff --git a/src/gui/itemviews/qtableview.cpp b/src/gui/itemviews/qtableview.cpp
index 6f532eb7c7..356f1873af 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/gui/itemviews/qtableview.cpp
@@ -3205,7 +3205,7 @@ void QTableView::selectionChanged(const QItemSelection &selected,
QModelIndex desel = deselected.indexes().value(0);
if (desel.isValid()) {
#ifdef Q_WS_X11
- int entry = d->accessibleTable2Index(sel);
+ int entry = d->accessibleTable2Index(desel);
QAccessible::updateAccessibility(this, entry, QAccessible::SelectionRemove);
#else
int entry = visualIndex(sel);
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 9228ac82a2..868cd92efb 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1378,6 +1378,23 @@ QItemViewPaintPairs QTreeViewPrivate::draggablePaintPairs(const QModelIndexList
return ret;
}
+void QTreeViewPrivate::adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex &current) const
+{
+ const int row = current.row();
+ option->state = option->state | (viewItems.at(row).expanded ? QStyle::State_Open : QStyle::State_None)
+ | (viewItems.at(row).hasChildren ? QStyle::State_Children : QStyle::State_None)
+ | (viewItems.at(row).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
+
+ option->showDecorationSelected = (selectionBehavior & QTreeView::SelectRows)
+ || option->showDecorationSelected;
+
+ QVector<int> logicalIndices;
+ QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
+ calcLogicalIndices(&logicalIndices, &viewItemPosList);
+ int logicalIndex = header->logicalIndex(current.column());
+ option->viewItemPosition = viewItemPosList.at(logicalIndex);
+}
+
/*!
\since 4.2
@@ -1463,6 +1480,59 @@ static inline bool ancestorOf(QObject *widget, QObject *other)
return false;
}
+void QTreeViewPrivate::calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const
+{
+ const int left = (spanning ? header->visualIndex(0) : leftAndRight.first);
+ const int right = (spanning ? header->visualIndex(0) : leftAndRight.second);
+ const int columnCount = header->count();
+ /* 'left' and 'right' are the left-most and right-most visible visual indices.
+ Compute the first visible logical indices before and after the left and right.
+ We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */
+ int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
+ for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {
+ int logicalIndex = header->logicalIndex(visualIndex);
+ if (!header->isSectionHidden(logicalIndex)) {
+ logicalIndexBeforeLeft = logicalIndex;
+ break;
+ }
+ }
+
+ for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) {
+ int logicalIndex = header->logicalIndex(visualIndex);
+ if (!header->isSectionHidden(logicalIndex)) {
+ if (visualIndex > right) {
+ logicalIndexAfterRight = logicalIndex;
+ break;
+ }
+ logicalIndices->append(logicalIndex);
+ }
+ }
+
+ itemPositions->resize(logicalIndices->count());
+ for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices->count(); ++currentLogicalSection) {
+ const int headerSection = logicalIndices->at(currentLogicalSection);
+ // determine the viewItemPosition depending on the position of column 0
+ int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices->count()
+ ? logicalIndexAfterRight
+ : logicalIndices->at(currentLogicalSection + 1);
+ int prevLogicalSection = currentLogicalSection - 1 < 0
+ ? logicalIndexBeforeLeft
+ : logicalIndices->at(currentLogicalSection - 1);
+ QStyleOptionViewItemV4::ViewItemPosition pos;
+ if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)
+ || (headerSection == 0 && nextLogicalSection == -1) || spanning)
+ pos = QStyleOptionViewItemV4::OnlyOne;
+ else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1))
+ pos = QStyleOptionViewItemV4::Beginning;
+ else if (nextLogicalSection == 0 || nextLogicalSection == -1)
+ pos = QStyleOptionViewItemV4::End;
+ else
+ pos = QStyleOptionViewItemV4::Middle;
+ (*itemPositions)[currentLogicalSection] = pos;
+ }
+}
+
+
/*!
Draws the row in the tree view that contains the model item \a index,
using the \a painter given. The \a option control how the item is
@@ -1531,33 +1601,13 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
int width, height = option.rect.height();
int position;
QModelIndex modelIndex;
- int columnCount = header->count();
const bool hoverRow = selectionBehavior() == QAbstractItemView::SelectRows
&& index.parent() == hover.parent()
&& index.row() == hover.row();
- /* 'left' and 'right' are the left-most and right-most visible visual indices.
- Compute the first visible logical indices before and after the left and right.
- We will use these values to determine the QStyleOptionViewItemV4::viewItemPosition. */
- int logicalIndexBeforeLeft = -1, logicalIndexAfterRight = -1;
- for (int visualIndex = left - 1; visualIndex >= 0; --visualIndex) {
- int logicalIndex = header->logicalIndex(visualIndex);
- if (!header->isSectionHidden(logicalIndex)) {
- logicalIndexBeforeLeft = logicalIndex;
- break;
- }
- }
- QVector<int> logicalIndices; // vector of currently visibly logical indices
- for (int visualIndex = left; visualIndex < columnCount; ++visualIndex) {
- int logicalIndex = header->logicalIndex(visualIndex);
- if (!header->isSectionHidden(logicalIndex)) {
- if (visualIndex > right) {
- logicalIndexAfterRight = logicalIndex;
- break;
- }
- logicalIndices.append(logicalIndex);
- }
- }
+ QVector<int> logicalIndices;
+ QVector<QStyleOptionViewItemV4::ViewItemPosition> viewItemPosList; // vector of left/middle/end for each logicalIndex
+ d->calcLogicalIndices(&logicalIndices, &viewItemPosList);
for (int currentLogicalSection = 0; currentLogicalSection < logicalIndices.count(); ++currentLogicalSection) {
int headerSection = logicalIndices.at(currentLogicalSection);
@@ -1579,22 +1629,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option,
continue;
opt.state = state;
- // determine the viewItemPosition depending on the position of column 0
- int nextLogicalSection = currentLogicalSection + 1 >= logicalIndices.count()
- ? logicalIndexAfterRight
- : logicalIndices.at(currentLogicalSection + 1);
- int prevLogicalSection = currentLogicalSection - 1 < 0
- ? logicalIndexBeforeLeft
- : logicalIndices.at(currentLogicalSection - 1);
- if (columnCount == 1 || (nextLogicalSection == 0 && prevLogicalSection == -1)
- || (headerSection == 0 && nextLogicalSection == -1) || spanning)
- opt.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
- else if (headerSection == 0 || (nextLogicalSection != 0 && prevLogicalSection == -1))
- opt.viewItemPosition = QStyleOptionViewItemV4::Beginning;
- else if (nextLogicalSection == 0 || nextLogicalSection == -1)
- opt.viewItemPosition = QStyleOptionViewItemV4::End;
- else
- opt.viewItemPosition = QStyleOptionViewItemV4::Middle;
+ opt.viewItemPosition = viewItemPosList.at(currentLogicalSection);
// fake activeness when row editor has focus
if (indexWidgetHasFocus)
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h
index a9dc452398..ef8f11c6c3 100644
--- a/src/gui/itemviews/qtreeview_p.h
+++ b/src/gui/itemviews/qtreeview_p.h
@@ -97,6 +97,7 @@ public:
void initialize();
QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
+ void adjustViewOptionsForIndex(QStyleOptionViewItemV4 *option, const QModelIndex &current) const;
#ifndef QT_NO_ANIMATION
struct AnimatedOperation : public QVariantAnimation
@@ -167,6 +168,10 @@ public:
void paintAlternatingRowColors(QPainter *painter, QStyleOptionViewItemV4 *option, int y, int bottom) const;
+ // logicalIndices: vector of currently visibly logical indices
+ // itemPositions: vector of view item positions (beginning/middle/end/onlyone)
+ void calcLogicalIndices(QVector<int> *logicalIndices, QVector<QStyleOptionViewItemV4::ViewItemPosition> *itemPositions) const;
+
QHeaderView *header;
int indent;
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp
index c472738254..19e7ba5a91 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -218,9 +218,9 @@ static bool aygResolved = false;
static void resolveAygLibs()
{
if (!aygResolved) {
- aygResolved = true;
QSystemLibrary ayglib(QLatin1String("aygshell"));
ptrRecognizeGesture = (AygRecognizeGesture) ayglib.resolve("SHRecognizeGesture");
+ aygResolved = true;
}
}
#endif // QT_NO_GESTURES
@@ -854,19 +854,15 @@ void qt_init(QApplicationPrivate *priv, int)
qt_win_initialize_directdraw();
#ifndef Q_OS_WINCE
- ptrUpdateLayeredWindowIndirect =
- (PtrUpdateLayeredWindowIndirect) QSystemLibrary::resolve(QLatin1String("user32"),
- "UpdateLayeredWindowIndirect");
- ptrUpdateLayeredWindow =
- (PtrUpdateLayeredWindow) QSystemLibrary::resolve(QLatin1String("user32"),
- "UpdateLayeredWindow");
+ QSystemLibrary user32(QLatin1String("user32"));
+ ptrUpdateLayeredWindowIndirect = (PtrUpdateLayeredWindowIndirect)user32.resolve("UpdateLayeredWindowIndirect");
+ ptrUpdateLayeredWindow = (PtrUpdateLayeredWindow)user32.resolve("UpdateLayeredWindow");
if (ptrUpdateLayeredWindow && !ptrUpdateLayeredWindowIndirect)
ptrUpdateLayeredWindowIndirect = qt_updateLayeredWindowIndirect;
// Notify Vista and Windows 7 that we support highter DPI settings
- ptrSetProcessDPIAware = (PtrSetProcessDPIAware)
- QSystemLibrary::resolve(QLatin1String("user32"), "SetProcessDPIAware");
+ ptrSetProcessDPIAware = (PtrSetProcessDPIAware)user32.resolve("SetProcessDPIAware");
if (ptrSetProcessDPIAware)
ptrSetProcessDPIAware();
#endif
@@ -886,29 +882,16 @@ void qt_init(QApplicationPrivate *priv, int)
priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs) &TKGetGestureExtraArguments;
#elif !defined(Q_WS_WINCE)
#if !defined(QT_NO_NATIVE_GESTURES)
- priv->GetGestureInfo =
- (PtrGetGestureInfo)QSystemLibrary::resolve(QLatin1String("user32"),
- "GetGestureInfo");
- priv->GetGestureExtraArgs =
- (PtrGetGestureExtraArgs)QSystemLibrary::resolve(QLatin1String("user32"),
- "GetGestureExtraArgs");
- priv->CloseGestureInfoHandle =
- (PtrCloseGestureInfoHandle)QSystemLibrary::resolve(QLatin1String("user32"),
- "CloseGestureInfoHandle");
- priv->SetGestureConfig =
- (PtrSetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
- "SetGestureConfig");
- priv->GetGestureConfig =
- (PtrGetGestureConfig)QSystemLibrary::resolve(QLatin1String("user32"),
- "GetGestureConfig");
+ priv->GetGestureInfo = (PtrGetGestureInfo)user32.resolve("GetGestureInfo");
+ priv->GetGestureExtraArgs = (PtrGetGestureExtraArgs)user32.resolve("GetGestureExtraArgs");
+ priv->CloseGestureInfoHandle = (PtrCloseGestureInfoHandle)user32.resolve("CloseGestureInfoHandle");
+ priv->SetGestureConfig = (PtrSetGestureConfig)user32.resolve("SetGestureConfig");
+ priv->GetGestureConfig = (PtrGetGestureConfig)user32.resolve("GetGestureConfig");
#endif // QT_NO_NATIVE_GESTURES
QSystemLibrary libTheme(QLatin1String("uxtheme"));
- priv->BeginPanningFeedback =
- (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback");
- priv->UpdatePanningFeedback =
- (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback");
- priv->EndPanningFeedback =
- (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback");
+ priv->BeginPanningFeedback = (PtrBeginPanningFeedback)libTheme.resolve("BeginPanningFeedback");
+ priv->UpdatePanningFeedback = (PtrUpdatePanningFeedback)libTheme.resolve("UpdatePanningFeedback");
+ priv->EndPanningFeedback = (PtrEndPanningFeedback)libTheme.resolve("EndPanningFeedback");
#endif
#endif // QT_NO_GESTURES
}
@@ -2388,15 +2371,14 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
break;
}
+#if !defined(Q_OS_WINCE)
typedef LRESULT (WINAPI *PtrLresultFromObject)(REFIID, WPARAM, LPUNKNOWN);
static PtrLresultFromObject ptrLresultFromObject = 0;
static bool oleaccChecked = false;
-
if (!oleaccChecked) {
+ QSystemLibrary oleacclib(QLatin1String("oleacc"));
+ ptrLresultFromObject = (PtrLresultFromObject)oleacclib.resolve("LresultFromObject");
oleaccChecked = true;
-#if !defined(Q_OS_WINCE)
- ptrLresultFromObject = (PtrLresultFromObject)QSystemLibrary::resolve(QLatin1String("oleacc"), "LresultFromObject");
-#endif
}
if (ptrLresultFromObject) {
QAccessibleInterface *acc = QAccessible::queryAccessibleInterface(widget);
@@ -2413,6 +2395,7 @@ extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wPa
if (res > 0)
RETURN(res);
}
+#endif
}
result = false;
break;
@@ -3198,8 +3181,8 @@ bool QETWidget::translateMouseEvent(const MSG &msg)
if (curWin != 0) {
if (!trackMouseEventLookup) {
- trackMouseEventLookup = true;
ptrTrackMouseEvent = (PtrTrackMouseEvent)QSystemLibrary::resolve(QLatin1String("comctl32"), "_TrackMouseEvent");
+ trackMouseEventLookup = true;
}
if (ptrTrackMouseEvent && !qApp->d_func()->inPopupMode()) {
// We always have to set the tracking, since
diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/gui/kernel/qguifunctions_wince.cpp
index 78dc469b88..ae2ca0418b 100644
--- a/src/gui/kernel/qguifunctions_wince.cpp
+++ b/src/gui/kernel/qguifunctions_wince.cpp
@@ -125,17 +125,16 @@ static AygInitDialog ptrAygInitDialog = 0;
static AygFullScreen ptrAygFullScreen = 0;
static AygSHSipInfo ptrAygSHSipInfo = 0;
static AygSHDoneButton ptrAygSHDoneButton = 0;
-static bool aygResolved = false;
-
static void resolveAygLibs()
{
+ static bool aygResolved = false;
if (!aygResolved) {
- aygResolved = true;
QLibrary ayglib(QLatin1String("aygshell"));
ptrAygInitDialog = (AygInitDialog) ayglib.resolve("SHInitDialog");
ptrAygFullScreen = (AygFullScreen) ayglib.resolve("SHFullScreen");
ptrAygSHSipInfo = (AygSHSipInfo) ayglib.resolve("SHSipInfo");
ptrAygSHDoneButton = (AygSHDoneButton) ayglib.resolve("SHDoneButton");
+ aygResolved = true;
}
}
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp
index 8b47d8e52a..e92bd495c4 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/gui/kernel/qmime_mac.cpp
@@ -520,13 +520,15 @@ static PtrGraphicsExportDoExport ptrGraphicsExportDoExport = 0;
static bool resolveMimeQuickTimeSymbols()
{
- if (ptrGraphicsImportSetDataHandle == 0) {
+ static bool triedResolve = false;
+ if (!triedResolve) {
QLibrary library(QLatin1String("/System/Library/Frameworks/QuickTime.framework/QuickTime"));
ptrGraphicsImportSetDataHandle = reinterpret_cast<PtrGraphicsImportSetDataHandle>(library.resolve("GraphicsImportSetDataHandle"));
ptrGraphicsImportCreateCGImage = reinterpret_cast<PtrGraphicsImportCreateCGImage>(library.resolve("GraphicsImportCreateCGImage"));
ptrGraphicsExportSetInputCGImage = reinterpret_cast<PtrGraphicsExportSetInputCGImage>(library.resolve("GraphicsExportSetInputCGImage"));
ptrGraphicsExportSetOutputHandle = reinterpret_cast<PtrGraphicsExportSetOutputHandle>(library.resolve("GraphicsExportSetOutputHandle"));
ptrGraphicsExportDoExport = reinterpret_cast<PtrGraphicsExportDoExport>(library.resolve("GraphicsExportDoExport"));
+ triedResolve = true;
}
return ptrGraphicsImportSetDataHandle != 0
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 342c4c6184..2244c11faf 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -221,7 +221,8 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
d->bars << bar;
if (d->bars.size() == 1) {
Q_ASSERT(d->animationFps> 0);
- d->animateTimer = startTimer(1000 / d->animationFps);
+ if (d->animateTimer == 0)
+ d->animateTimer = startTimer(1000 / d->animationFps);
}
}
}
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 997d429add..55254689aa 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -2586,7 +2586,6 @@ bool QWindowsVistaStylePrivate::resolveSymbols()
{
static bool tried = false;
if (!tried) {
- tried = true;
QSystemLibrary themeLib(QLatin1String("uxtheme"));
pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme");
pIsThemePartDefined = (PtrIsThemePartDefined )themeLib.resolve("IsThemePartDefined");
@@ -2611,6 +2610,7 @@ bool QWindowsVistaStylePrivate::resolveSymbols()
pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
pGetThemeTransitionDuration = (PtrGetThemeTransitionDuration)themeLib.resolve("GetThemeTransitionDuration");
pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
+ tried = true;
}
return pGetThemeTransitionDuration != 0;
}
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 343f262483..9934545fea 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -343,7 +343,6 @@ bool QWindowsXPStylePrivate::resolveSymbols()
{
static bool tried = false;
if (!tried) {
- tried = true;
QSystemLibrary themeLib(QLatin1String("uxtheme"));
pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
if (pIsAppThemed) {
@@ -372,6 +371,7 @@ bool QWindowsXPStylePrivate::resolveSymbols()
pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty");
pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent");
}
+ tried = true;
}
return pIsAppThemed != 0;
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index fc11387367..bb5e041a33 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -138,8 +138,11 @@ static void resolveGetCharWidthI()
{
if (resolvedGetCharWidthI)
return;
+
+ QSystemLibrary gdi32(QLatin1String("gdi32"));
+ ptrGetCharWidthI = (PtrGetCharWidthI)gdi32.resolve("GetCharWidthI");
+
resolvedGetCharWidthI = true;
- ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
}
#endif // !defined(Q_WS_WINCE)
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index aeeef85c9e..5babbc22ef 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -408,7 +408,6 @@ void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QText
setContent(format, text, document);
doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable);
- q->setCursorWidth(-1);
}
void QTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document)
@@ -2236,7 +2235,10 @@ int QTextControl::cursorWidth() const
{
#ifndef QT_NO_PROPERTIES
Q_D(const QTextControl);
- return d->doc->documentLayout()->property("cursorWidth").toInt();
+ int width = d->doc->documentLayout()->property("cursorWidth").toInt();
+ if (width == -1)
+ width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
+ return width;
#else
return 1;
#endif
@@ -2248,8 +2250,6 @@ void QTextControl::setCursorWidth(int width)
#ifdef QT_NO_PROPERTIES
Q_UNUSED(width);
#else
- if (width == -1)
- width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
d->doc->documentLayout()->setProperty("cursorWidth", width);
#endif
d->repaintCursor();
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/gui/widgets/qmenu_wince.cpp
index b0c6c1bd12..d45daf8c25 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/gui/widgets/qmenu_wince.cpp
@@ -111,10 +111,10 @@ static AygEnableSoftKey ptrEnableSoftKey = 0;
static void resolveAygLibs()
{
if (!aygResolved) {
- aygResolved = true;
QLibrary aygLib(QLatin1String("aygshell"));
ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar");
ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey");
+ aygResolved = true;
}
}