diff options
Diffstat (limited to 'src')
28 files changed, 230 insertions, 235 deletions
diff --git a/src/activeqt/shared/qaxtypes.cpp b/src/activeqt/shared/qaxtypes.cpp index 8835caf..9452c6a 100644 --- a/src/activeqt/shared/qaxtypes.cpp +++ b/src/activeqt/shared/qaxtypes.cpp @@ -665,9 +665,9 @@ bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &type static PGetRecordInfoFromTypeInfo pGetRecordInfoFromTypeInfo = 0; static bool resolved = false; if (!resolved) { + QSystemLibrary oleaut32(QLatin1String("oleaut32")); + pGetRecordInfoFromTypeInfo = (PGetRecordInfoFromTypeInfo)oleaut32.resolve("GetRecordInfoFromTypeInfo"); resolved = true; - pGetRecordInfoFromTypeInfo = (PGetRecordInfoFromTypeInfo)QSystemLibrary::resolve(QLatin1String("oleaut32"), - "GetRecordInfoFromTypeInfo"); } if (!pGetRecordInfoFromTypeInfo) break; diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 98404a5..338552c 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -186,14 +186,13 @@ static void resolveLibs() } #endif - triedResolve = true; #if !defined(Q_OS_WINCE) - HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32"); - if (advapiHnd) { - ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); - ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); - ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); - ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); + QSystemLibrary advapi32(QLatin1String("advapi32")); + if (advapi32.load()) { + ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)advapi32.resolve("GetNamedSecurityInfoW"); + ptrLookupAccountSidW = (PtrLookupAccountSidW)advapi32.resolve("LookupAccountSidW"); + ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)advapi32.resolve("BuildTrusteeWithSidW"); + ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)advapi32.resolve("GetEffectiveRightsFromAclW"); } if (ptrBuildTrusteeWithSidW) { // Create TRUSTEE for current user @@ -208,9 +207,9 @@ static void resolveLibs() } typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); - PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); + PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)advapi32.resolve("AllocateAndInitializeSid"); typedef PVOID (WINAPI *PtrFreeSid)(PSID); - PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); + PtrFreeSid ptrFreeSid = (PtrFreeSid)advapi32.resolve("FreeSid"); if (ptrAllocateAndInitializeSid && ptrFreeSid) { // Create TRUSTEE for Everyone (World) SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; @@ -220,13 +219,16 @@ static void resolveLibs() ptrFreeSid(pWorld); } } - HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv"); - if (userenvHnd) - ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); - HINSTANCE kernel32 = LoadLibrary(L"kernel32"); - if(kernel32) - ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW"); + + QSystemLibrary userenv(QLatin1String("userenv")); + if (userenv.load()) + ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)userenv.resolve("GetUserProfileDirectoryW"); + + QSystemLibrary kernel32(QLatin1String("kernel32")); + if (kernel32.load()) + ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)kernel32.resolve("GetVolumePathNamesForVolumeNameW"); #endif + triedResolve = true; } } #endif // QT_NO_LIBRARY @@ -252,15 +254,15 @@ static bool resolveUNCLibs() return ptrNetShareEnum && ptrNetApiBufferFree; } #endif - triedResolve = true; + #if !defined(Q_OS_WINCE) - HINSTANCE hLib = QSystemLibrary::load(L"Netapi32"); - if (hLib) { - ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum"); - if (ptrNetShareEnum) - ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree"); + QSystemLibrary netapi32(QLatin1String("Netapi32")); + if (netapi32.load()) { + ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum"); + ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree"); } #endif + triedResolve = true; } return ptrNetShareEnum && ptrNetApiBufferFree; } diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 84663fa..c135c4a 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -53,7 +53,6 @@ #include "qabstracteventdispatcher_p.h" #include "qcoreapplication_p.h" #include <private/qthread_p.h> -#include <private/qmutexpool_p.h> QT_BEGIN_NAMESPACE @@ -322,19 +321,17 @@ static void resolveTimerAPI() { static bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - if (triedResolve) - return; -#endif - triedResolve = true; -#if !defined(Q_OS_WINCE) - qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent"); - qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent"); +#ifndef Q_OS_WINCE + QSystemLibrary library(QLatin1String("Mmtimer")); #else - qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent"); - qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent"); + QSystemLibrary library(QLatin1String("winmm")); #endif + if (library.load()) { + qtimeSetEvent = (ptimeSetEvent)library.resolve("timeSetEvent"); + qtimeKillEvent = (ptimeKillEvent)library.resolve("timeKillEvent"); + } + + triedResolve = true; } } diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp index bb9c82a..7296c5b 100644 --- a/src/corelib/plugin/qsystemlibrary.cpp +++ b/src/corelib/plugin/qsystemlibrary.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsystemlibrary_p.h" + #include <QtCore/qvarlengtharray.h> #include <QtCore/qstringlist.h> #include <QtCore/qfileinfo.h> @@ -91,7 +92,7 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect extern QString qAppFileName(); #endif -static QString qSystemDirectory() +static inline QString qSystemDirectory() { QVarLengthArray<wchar_t, MAX_PATH> fullPath; @@ -115,27 +116,25 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect searchOrder << qSystemDirectory(); if (!onlySystemDirectory) { - const QString PATH(QLatin1String(qgetenv("PATH").constData())); + const QString PATH = QString::fromWCharArray((const wchar_t *)_wgetenv(L"PATH")); searchOrder << PATH.split(QLatin1Char(';'), QString::SkipEmptyParts); } - QString fileName = QString::fromWCharArray(libraryName); - fileName.append(QLatin1String(".dll")); + const QString fileName = QString::fromWCharArray(libraryName) + QLatin1String(".dll"); // Start looking in the order specified for (int i = 0; i < searchOrder.count(); ++i) { QString fullPathAttempt = searchOrder.at(i); - if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) { + if (!fullPathAttempt.endsWith(QLatin1Char('\\'))) fullPathAttempt.append(QLatin1Char('\\')); - } fullPathAttempt.append(fileName); HINSTANCE inst = ::LoadLibrary((const wchar_t *)fullPathAttempt.utf16()); if (inst != 0) return inst; } - return 0; + return 0; } -#endif //Q_OS_WINCE +#endif // !Q_OS_WINCE QT_END_NAMESPACE diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h index f20d0b6..88ab82c 100644 --- a/src/corelib/plugin/qsystemlibrary_p.h +++ b/src/corelib/plugin/qsystemlibrary_p.h @@ -85,9 +85,9 @@ public: if (!m_handle) return 0; #ifdef Q_OS_WINCE - return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()); + return (void*)GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()); #else - return (void*)GetProcAddress(m_handle, symbol); + return (void*)GetProcAddress(m_handle, symbol); #endif } @@ -97,6 +97,7 @@ public: } static Q_CORE_EXPORT HINSTANCE load(const wchar_t *lpFileName, bool onlySystemDirectory = true); + private: HINSTANCE m_handle; QString m_libraryName; @@ -105,6 +106,6 @@ private: QT_END_NAMESPACE -#endif //Q_OS_WIN +#endif // Q_OS_WIN -#endif //QSYSTEMLIBRARY_P_H +#endif // QSYSTEMLIBRARY_P_H diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index d79dc5d..e6bce27 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -42,6 +42,8 @@ #include "qelapsedtimer.h" #include <windows.h> +#include <private/qsystemlibrary_p.h> + typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void); static PtrGetTickCount64 ptrGetTickCount64 = 0; @@ -52,21 +54,17 @@ static quint64 counterFrequency = 0; static void resolveLibs() { - static bool done = false; + static volatile bool done = false; if (done) return; // try to get GetTickCount64 from the system - HMODULE kernel32 = GetModuleHandleW(L"kernel32"); - if (!kernel32) + QSystemLibrary kernel32(QLatin1String("kernel32")); + if (!kernel32.load()) return; -#if defined(Q_OS_WINCE) // does this function exist on WinCE, or will ever exist? - ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, L"GetTickCount64"); -#else - ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64"); -#endif + ptrGetTickCount64 = (PtrGetTickCount64)kernel32.resolve("GetTickCount64"); // Retrieve the number of high-resolution performance counter ticks per second LARGE_INTEGER frequency; diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index 1fd1bfd..c1bb54b 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; diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 6691ff1..2d4769a 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 9ea114c..00ebbfd 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 9092593..f7ae045 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 47b6eef..aa1571b 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 ded4d63..1676c46 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 ¤t = 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 04babde..b742529 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/qtableview.cpp b/src/gui/itemviews/qtableview.cpp index 6f532eb..356f187 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 9228ac8..868cd92 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 ¤t) 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 a9dc452..ef8f11c 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 ¤t) 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 c472738..19e7ba5 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 78dc469..ae2ca04 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 8b47d8e..e92bd49 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 342c4c6..2244c11 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 997d429..5525468 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 343f262..9934545 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 fc11387..bb5e041 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 aeeef85..5babbc2 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 b0c6c1b..d45daf8 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; } } diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 1052863..58a5bee 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -45,9 +45,7 @@ #include "private/qnativesocketengine_p.h" #include <ws2tcpip.h> #include <private/qsystemlibrary_p.h> -#include <qmutex.h> #include <qurl.h> -#include <private/qmutexpool_p.h> QT_BEGIN_NAMESPACE @@ -84,15 +82,22 @@ static void resolveLibrary() { // Attempt to resolve getaddrinfo(); without it we'll have to fall // back to gethostbyname(), which has no IPv6 support. + static bool triedResolve = false; + if (triedResolve) + return; + #if !defined(Q_OS_WINCE) - local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getaddrinfo"); - local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "freeaddrinfo"); - local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2_32"), "getnameinfo"); + QSystemLibrary ws2lib(QLatin1String("ws2_32")); #else - local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getaddrinfo"); - local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "freeaddrinfo"); - local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getnameinfo"); + QSystemLibrary ws2lib(QLatin1String("ws2")); #endif + if (ws2lib.load()) { + local_getaddrinfo = (getaddrinfoProto)ws2lib.resolve("getaddrinfo"); + local_freeaddrinfo = (freeaddrinfoProto)ws2lib.resolve("freeaddrinfo"); + local_getnameinfo = (getnameinfoProto)ws2lib.resolve("getnameinfo"); + } + + triedResolve = true; } #if defined(Q_OS_WINCE) @@ -102,22 +107,14 @@ Q_GLOBAL_STATIC(QMutex, qPrivCEMutex) QHostInfo QHostInfoAgent::fromName(const QString &hostName) { + resolveLibrary(); + #if defined(Q_OS_WINCE) QMutexLocker locker(qPrivCEMutex()); #endif QWindowsSockInit winSock; - // Load res_init on demand. - static volatile bool triedResolve = false; - if (!triedResolve) { - QMutexLocker locker(QMutexPool::globalInstanceGet(&local_getaddrinfo)); - if (!triedResolve) { - resolveLibrary(); - triedResolve = true; - } - } - QHostInfo results; #if defined(QHOSTINFO_DEBUG) diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index e8b96f6..a624468 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -63,23 +63,14 @@ static void resolveLibs() { // try to find the functions we need from Iphlpapi.dll static bool done = false; - if (!done) { + QSystemLibrary iphlpapi(QLatin1String("iphlpapi")); + if (iphlpapi.load()) { + ptrGetAdaptersInfo = (PtrGetAdaptersInfo)iphlpapi.resolve("GetAdaptersInfo"); + ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)iphlpapi.resolve("GetAdaptersAddresses"); + ptrGetNetworkParams = (PtrGetNetworkParams)iphlpapi.resolve("GetNetworkParams"); + } done = true; - - HINSTANCE iphlpapiHnd = QSystemLibrary::load(L"iphlpapi"); - if (iphlpapiHnd == NULL) - return; - -#if defined(Q_OS_WINCE) - ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, L"GetAdaptersInfo"); - ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddress(iphlpapiHnd, L"GetAdaptersAddresses"); - ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddress(iphlpapiHnd, L"GetNetworkParams"); -#else - ptrGetAdaptersInfo = (PtrGetAdaptersInfo)GetProcAddress(iphlpapiHnd, "GetAdaptersInfo"); - ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)GetProcAddress(iphlpapiHnd, "GetAdaptersAddresses"); - ptrGetNetworkParams = (PtrGetNetworkParams)GetProcAddress(iphlpapiHnd, "GetNetworkParams"); -#endif } } diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp index ce7d906..d279631 100644 --- a/src/plugins/bearer/nativewifi/main.cpp +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -42,51 +42,42 @@ #include "qnativewifiengine.h" #include "platformdefs.h" -#include <QtCore/qmutex.h> -#include <QtCore/private/qmutexpool_p.h> -#include <QtCore/qlibrary.h> +#include <QtCore/private/qsystemlibrary_p.h> #include <QtNetwork/private/qbearerplugin_p.h> -#include <QtCore/qdebug.h> - #ifndef QT_NO_BEARERMANAGEMENT QT_BEGIN_NAMESPACE static void resolveLibrary() { - static volatile bool triedResolve = false; - + static bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle)); -#endif - - if (!triedResolve) { + QSystemLibrary wlanapi(QLatin1String("wlanapi")); + if (wlanapi.load()) { local_WlanOpenHandle = (WlanOpenHandleProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle"); + wlanapi.resolve("WlanOpenHandle"); local_WlanRegisterNotification = (WlanRegisterNotificationProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification"); + wlanapi.resolve("WlanRegisterNotification"); local_WlanEnumInterfaces = (WlanEnumInterfacesProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces"); + wlanapi.resolve("WlanEnumInterfaces"); local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList"); + wlanapi.resolve("WlanGetAvailableNetworkList"); local_WlanQueryInterface = (WlanQueryInterfaceProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface"); + wlanapi.resolve("WlanQueryInterface"); local_WlanConnect = (WlanConnectProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect"); + wlanapi.resolve("WlanConnect"); local_WlanDisconnect = (WlanDisconnectProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect"); + wlanapi.resolve("WlanDisconnect"); local_WlanScan = (WlanScanProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan"); + wlanapi.resolve("WlanScan"); local_WlanFreeMemory = (WlanFreeMemoryProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory"); + wlanapi.resolve("WlanFreeMemory"); local_WlanCloseHandle = (WlanCloseHandleProto) - QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle"); - - triedResolve = true; + wlanapi.resolve("WlanCloseHandle"); } + triedResolve = true; } } |