From 2c1e828af311bb103a6f02513cd339973e9582f6 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 28 Sep 2011 17:11:31 +0200 Subject: Fix typo when updating accessible treeview selection. Reviewed-by: Gabi --- src/gui/itemviews/qtableview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- cgit v0.12 From d63910575949106f84dacf04abaa14fc866aa66b Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 3 Dec 2010 11:34:09 +0100 Subject: Set missing flags in the option when rendering QTreeView drag pixmap QAbstractItemViewPrivate::renderToPixmap was not setting all the flags that the normal QTreeView painting sets: option.showDecorationSelected, option.viewItemPosition (so the drag pixmap looked wrong on Windows 7, with rects around each cell), and then the unittest also discovered that State_Children/State_Sibling wasn't set either. Task-number: QTBUG-15834 Merge-request: 2517 Reviewed-by: Gabriel --- src/gui/itemviews/qabstractitemview.cpp | 1 + src/gui/itemviews/qabstractitemview_p.h | 2 + src/gui/itemviews/qtreeview.cpp | 113 +++++++++++++++++++++----------- src/gui/itemviews/qtreeview_p.h | 5 ++ tests/auto/qtreeview/tst_qtreeview.cpp | 11 +++- 5 files changed, 92 insertions(+), 40 deletions(-) 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/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 logicalIndices; + QVector 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 *logicalIndices, QVector *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 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 logicalIndices; + QVector 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 *logicalIndices, QVector *itemPositions) const; + QHeaderView *header; int indent; diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index facb982..c37a4ea 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -45,6 +45,7 @@ #include #include +#include #include "../../shared/util.h" //TESTED_CLASS= @@ -112,6 +113,8 @@ struct PublicView : public QTreeView inline QStyleOptionViewItem viewOptions() const { return QTreeView::viewOptions(); } inline int sizeHintForColumn(int column) const { return QTreeView::sizeHintForColumn(column); } + inline void startDrag(Qt::DropActions supportedActions) { QTreeView::startDrag(supportedActions); } + QAbstractItemViewPrivate* aiv_priv() { return static_cast(d_ptr.data()); } }; class tst_QTreeView : public QObject @@ -2947,7 +2950,7 @@ void tst_QTreeView::styleOptionViewItem() bool allCollapsed; }; - QTreeView view; + PublicView view; QStandardItemModel model; view.setModel(&model); MyDelegate delegate; @@ -3006,6 +3009,12 @@ void tst_QTreeView::styleOptionViewItem() QApplication::processEvents(); QTRY_VERIFY(delegate.count >= 4); + // test that the rendering of drag pixmap sets the correct options too (QTBUG-15834) + delegate.count = 0; + QItemSelection sel(model.index(0,0), model.index(0,3)); + QRect rect; + view.aiv_priv()->renderToPixmap(sel.indexes(), &rect); + QTRY_VERIFY(delegate.count >= 4); //test dynamic models { -- cgit v0.12 From 7d9ac9659568f77d3acf70f304fa152d3ecadcb1 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 29 Sep 2011 14:36:33 +0200 Subject: don't assume the PATH envvar is latin1-encoded use Unicode getenv() version instead Merge-request: 1344 Reviewed-by: Jan-Arve Saether --- src/corelib/plugin/qsystemlibrary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp index bb9c82a..c983f38 100644 --- a/src/corelib/plugin/qsystemlibrary.cpp +++ b/src/corelib/plugin/qsystemlibrary.cpp @@ -115,7 +115,7 @@ 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); -- cgit v0.12 From 569228bb5d7759025f06b1963f3d4a1fc4e05694 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Thu, 29 Sep 2011 14:36:44 +0200 Subject: nano-opts, styling fixes Merge-request: 1344 Reviewed-by: Jan-Arve Saether --- src/corelib/plugin/qsystemlibrary.cpp | 13 ++++++------- src/corelib/plugin/qsystemlibrary_p.h | 9 +++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp index c983f38..7296c5b 100644 --- a/src/corelib/plugin/qsystemlibrary.cpp +++ b/src/corelib/plugin/qsystemlibrary.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qsystemlibrary_p.h" + #include #include #include @@ -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 fullPath; @@ -118,24 +119,22 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect 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 -- cgit v0.12 From f3f65928525465e20f40e89d0855a1f32de6d8a4 Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 29 Sep 2011 14:54:15 +0200 Subject: Fix bug in QGraphicsItem::isVisibleTo(). Task-number: QTBUG-21612 Reviewed-by: James Perrett Reviewed-by: Magne Pettersen Zachrisen Merge-request: 1396 Reviewed-by: Jan-Arve Saether --- src/gui/graphicsview/qgraphicsitem.cpp | 20 ++--- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 108 +++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 9 deletions(-) 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/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 9b834d5..b6a402e 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -306,6 +306,7 @@ private slots: void inputMethodHints(); void toolTip(); void visible(); + void isVisibleTo(); void explicitlyVisible(); void enabled(); void explicitlyEnabled(); @@ -1138,6 +1139,113 @@ void tst_QGraphicsItem::visible() QVERIFY(!item->hasFocus()); } +void tst_QGraphicsItem::isVisibleTo() +{ + QGraphicsScene scene; + QGraphicsItem *parent = scene.addRect(QRectF(0, 0, 100, 100)); + QGraphicsItem *child = scene.addRect(QRectF(25, 25, 50, 50)); + QGraphicsItem *grandChild = scene.addRect(QRectF(50, 50, 50, 50)); + QGraphicsItem *stranger = scene.addRect(100, 100, 100, 100); + + child->setParentItem(parent); + grandChild->setParentItem(child); + + QVERIFY(grandChild->isVisible()); + QVERIFY(grandChild->isVisibleTo(grandChild)); + QVERIFY(grandChild->isVisibleTo(child)); + QVERIFY(grandChild->isVisibleTo(parent)); + QVERIFY(grandChild->isVisibleTo(0)); + QVERIFY(child->isVisible()); + QVERIFY(child->isVisibleTo(child)); + QVERIFY(child->isVisibleTo(parent)); + QVERIFY(child->isVisibleTo(0)); + QVERIFY(parent->isVisible()); + QVERIFY(parent->isVisibleTo(parent)); + QVERIFY(parent->isVisibleTo(0)); + QVERIFY(!parent->isVisibleTo(child)); + QVERIFY(!child->isVisibleTo(grandChild)); + QVERIFY(!grandChild->isVisibleTo(stranger)); + QVERIFY(!child->isVisibleTo(stranger)); + QVERIFY(!parent->isVisibleTo(stranger)); + QVERIFY(!stranger->isVisibleTo(grandChild)); + QVERIFY(!stranger->isVisibleTo(child)); + QVERIFY(!stranger->isVisibleTo(parent)); + + // Case 1: only parent is explicitly hidden + parent->hide(); + + QVERIFY(!grandChild->isVisible()); + QVERIFY(grandChild->isVisibleTo(grandChild)); + QVERIFY(grandChild->isVisibleTo(child)); + QVERIFY(grandChild->isVisibleTo(parent)); + QVERIFY(!grandChild->isVisibleTo(0)); + QVERIFY(!child->isVisible()); + QVERIFY(child->isVisibleTo(child)); + QVERIFY(child->isVisibleTo(parent)); + QVERIFY(!child->isVisibleTo(0)); + QVERIFY(!parent->isVisible()); + QVERIFY(!parent->isVisibleTo(parent)); + QVERIFY(!parent->isVisibleTo(0)); + QVERIFY(!parent->isVisibleTo(child)); + QVERIFY(!child->isVisibleTo(grandChild)); + QVERIFY(!grandChild->isVisibleTo(stranger)); + QVERIFY(!child->isVisibleTo(stranger)); + QVERIFY(!parent->isVisibleTo(stranger)); + QVERIFY(!stranger->isVisibleTo(grandChild)); + QVERIFY(!stranger->isVisibleTo(child)); + QVERIFY(!stranger->isVisibleTo(parent)); + + // Case 2: only child is hidden + parent->show(); + child->hide(); + + QVERIFY(!grandChild->isVisible()); + QVERIFY(grandChild->isVisibleTo(grandChild)); + QVERIFY(grandChild->isVisibleTo(child)); + QVERIFY(!grandChild->isVisibleTo(parent)); + QVERIFY(!grandChild->isVisibleTo(0)); + QVERIFY(!child->isVisible()); + QVERIFY(!child->isVisibleTo(child)); + QVERIFY(!child->isVisibleTo(parent)); + QVERIFY(!child->isVisibleTo(0)); + QVERIFY(parent->isVisible()); + QVERIFY(parent->isVisibleTo(parent)); + QVERIFY(parent->isVisibleTo(0)); + QVERIFY(!parent->isVisibleTo(child)); + QVERIFY(!child->isVisibleTo(grandChild)); + QVERIFY(!grandChild->isVisibleTo(stranger)); + QVERIFY(!child->isVisibleTo(stranger)); + QVERIFY(!parent->isVisibleTo(stranger)); + QVERIFY(!stranger->isVisibleTo(grandChild)); + QVERIFY(!stranger->isVisibleTo(child)); + QVERIFY(!stranger->isVisibleTo(parent)); + + // Case 3: only grand child is hidden + child->show(); + grandChild->hide(); + + QVERIFY(!grandChild->isVisible()); + QVERIFY(!grandChild->isVisibleTo(grandChild)); + QVERIFY(!grandChild->isVisibleTo(child)); + QVERIFY(!grandChild->isVisibleTo(parent)); + QVERIFY(!grandChild->isVisibleTo(0)); + QVERIFY(child->isVisible()); + QVERIFY(child->isVisibleTo(child)); + QVERIFY(child->isVisibleTo(parent)); + QVERIFY(child->isVisibleTo(0)); + QVERIFY(parent->isVisible()); + QVERIFY(parent->isVisibleTo(parent)); + QVERIFY(parent->isVisibleTo(0)); + QVERIFY(!parent->isVisibleTo(child)); + QVERIFY(!child->isVisibleTo(grandChild)); + QVERIFY(!grandChild->isVisibleTo(stranger)); + QVERIFY(!child->isVisibleTo(stranger)); + QVERIFY(!parent->isVisibleTo(stranger)); + QVERIFY(!stranger->isVisibleTo(grandChild)); + QVERIFY(!stranger->isVisibleTo(child)); + QVERIFY(!stranger->isVisibleTo(parent)); +} + void tst_QGraphicsItem::explicitlyVisible() { QGraphicsScene scene; -- cgit v0.12 From aefda8ce30695c5383860eab709acca345d290dc Mon Sep 17 00:00:00 2001 From: Mikko Knuutila Date: Tue, 4 Oct 2011 15:00:27 +0200 Subject: QTBUG-21058: Fix for possible crashes in QTextControl::setCursorWidth() Cursor's width is now queried from the style only when the user calls cursorWidth(). Earlier it was queried already in the ctor, which caused crashes if the application was guiless. Merge-request: 2697 Reviewed-by: Jan-Arve Saether --- src/gui/text/qtextcontrol.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(); -- cgit v0.12 From 48a73353029104a4d2c5fda2c9fb007d1924c9ec Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:12 +0200 Subject: make QElapsedTimer use QSystemLibrary on win we also need to ensure the counterFrequency was already set up, thus volatile (which fixes possible race condition) Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/corelib/tools/qelapsedtimer_win.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 +#include + 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; -- cgit v0.12 From 80a8c4c8615da574b155b7624eab1c8323de3ee3 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:19 +0200 Subject: nativewifi bearer plugin: prefer DLL Safe Search mode by using QSystemLibrary instead of QLibrary Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/plugins/bearer/nativewifi/main.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp index ce7d906..cbdfd99 100644 --- a/src/plugins/bearer/nativewifi/main.cpp +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #include @@ -63,30 +63,33 @@ static void resolveLibrary() QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle)); #endif - if (!triedResolve) { + if (triedResolve) + return; + + 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; } } -- cgit v0.12 From 1bfef526ef3d1deb7cf0f11dc1880f33937a85ac Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:26 +0200 Subject: use QSystemLibrary::resolve() instead of GetProcAddress() win API calls this makes the code more consistent with similar parts and a bit more readable Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/corelib/io/qfilesystemengine_win.cpp | 39 ++++++++++++++-------------- src/gui/dialogs/qfiledialog_win.cpp | 10 +++---- src/network/kernel/qnetworkinterface_win.cpp | 19 +++++--------- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 98404a5..8622121 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -188,12 +188,12 @@ static void resolveLibs() 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 +208,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,12 +220,14 @@ 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 } } @@ -254,11 +256,10 @@ static bool resolveUNCLibs() #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("kernel32")); + if (netapi32.load()) { + ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum"); + ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree"); } #endif } diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index de8e33d..30f5f18 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -99,16 +99,16 @@ static void qt_win_resolve_libs() 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 diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index e8b96f6..5f273d7 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -67,19 +67,12 @@ static void resolveLibs() if (!done) { 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 + QSystemLibrary iphlpapi(QLatin1String("iphlpapi")); + if (iphlpapi.load()) { + ptrGetAdaptersInfo = (PtrGetAdaptersInfo)iphlpapi.resolve("GetAdaptersInfo"); + ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)iphlpapi.resolve("GetAdaptersAddresses"); + ptrGetNetworkParams = (PtrGetNetworkParams)iphlpapi.resolve("GetNetworkParams"); + } } } -- cgit v0.12 From 74251fb0fc57b1e0f7db0b561e4aa4c0347f6f37 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:33 +0200 Subject: simplify the code by using QSystemLibrary a bit smarter Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/corelib/kernel/qeventdispatcher_win.cpp | 12 +++++---- src/gui/kernel/qapplication_win.cpp | 41 +++++++++-------------------- src/network/kernel/qhostinfo_win.cpp | 13 ++++----- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 84663fa..3e367b7 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -328,13 +328,15 @@ static void resolveTimerAPI() 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"); + } } } diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 756cb56..bca3acc 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -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 } diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 6fc5b7b..03e72c4 100644 --- a/src/network/kernel/qhostinfo_win.cpp +++ b/src/network/kernel/qhostinfo_win.cpp @@ -85,14 +85,15 @@ static void resolveLibrary() // Attempt to resolve getaddrinfo(); without it we'll have to fall // back to gethostbyname(), which has no IPv6 support. #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"); + } } #if defined(Q_OS_WINCE) -- cgit v0.12 From a0feeef52efde872c6d6e458c8e15616da0bf74f Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:40 +0200 Subject: fix possible race conditions the initialization guard must be set after the initialization is done; for the code assumed to be only executed in a single thread, this change was done just for consistency - in order to avoid similar issues by copy-pasting in future Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/activeqt/shared/qaxtypes.cpp | 4 ++-- src/corelib/io/qfilesystemengine_win.cpp | 5 +++-- src/corelib/kernel/qeventdispatcher_win.cpp | 3 ++- src/gui/accessible/qaccessible_win.cpp | 2 +- src/gui/dialogs/qfiledialog_win.cpp | 3 ++- src/gui/dialogs/qwizard_win.cpp | 2 +- src/gui/image/qpixmap_mac.cpp | 4 +++- src/gui/kernel/qapplication_win.cpp | 12 ++++++------ src/gui/kernel/qguifunctions_wince.cpp | 5 ++--- src/gui/kernel/qmime_mac.cpp | 4 +++- src/gui/styles/qwindowsvistastyle.cpp | 2 +- src/gui/styles/qwindowsxpstyle.cpp | 2 +- src/gui/text/qfontengine_win.cpp | 5 ++++- src/gui/widgets/qmenu_wince.cpp | 2 +- src/network/kernel/qnetworkinterface_win.cpp | 4 +--- 15 files changed, 33 insertions(+), 26 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 8622121..218cf20 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -186,7 +186,6 @@ static void resolveLibs() } #endif - triedResolve = true; #if !defined(Q_OS_WINCE) QSystemLibrary advapi32(QLatin1String("advapi32")); if (advapi32.load()) { @@ -229,6 +228,7 @@ static void resolveLibs() if (kernel32.load()) ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)kernel32.resolve("GetVolumePathNamesForVolumeNameW"); #endif + triedResolve = true; } } #endif // QT_NO_LIBRARY @@ -254,7 +254,7 @@ static bool resolveUNCLibs() return ptrNetShareEnum && ptrNetApiBufferFree; } #endif - triedResolve = true; + #if !defined(Q_OS_WINCE) QSystemLibrary netapi32(QLatin1String("kernel32")); if (netapi32.load()) { @@ -262,6 +262,7 @@ static bool resolveUNCLibs() 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 3e367b7..365b28e 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -327,7 +327,6 @@ static void resolveTimerAPI() if (triedResolve) return; #endif - triedResolve = true; #ifndef Q_OS_WINCE QSystemLibrary library(QLatin1String("Mmtimer")); #else @@ -337,6 +336,8 @@ static void resolveTimerAPI() qtimeSetEvent = (ptimeSetEvent)library.resolve("timeSetEvent"); qtimeKillEvent = (ptimeKillEvent)library.resolve("timeKillEvent"); } + + triedResolve = true; } } 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 30f5f18..45f6164 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -97,7 +97,6 @@ static void qt_win_resolve_libs() } #endif - triedResolve = true; #if !defined(Q_WS_WINCE) QSystemLibrary lib(QLatin1String("shell32")); ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW"); @@ -112,6 +111,8 @@ static void qt_win_resolve_libs() 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/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/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index bca3acc..b84fe56 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 @@ -2371,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); @@ -2396,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; @@ -3181,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(library.resolve("GraphicsImportSetDataHandle")); ptrGraphicsImportCreateCGImage = reinterpret_cast(library.resolve("GraphicsImportCreateCGImage")); ptrGraphicsExportSetInputCGImage = reinterpret_cast(library.resolve("GraphicsExportSetInputCGImage")); ptrGraphicsExportSetOutputHandle = reinterpret_cast(library.resolve("GraphicsExportSetOutputHandle")); ptrGraphicsExportDoExport = reinterpret_cast(library.resolve("GraphicsExportDoExport")); + triedResolve = true; } return ptrGraphicsImportSetDataHandle != 0 diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index b894eb4..f991cbc 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 3c33df3..dd7f1f6 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/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/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp index 5f273d7..a624468 100644 --- a/src/network/kernel/qnetworkinterface_win.cpp +++ b/src/network/kernel/qnetworkinterface_win.cpp @@ -63,16 +63,14 @@ static void resolveLibs() { // try to find the functions we need from Iphlpapi.dll static bool done = false; - if (!done) { - done = true; - QSystemLibrary iphlpapi(QLatin1String("iphlpapi")); if (iphlpapi.load()) { ptrGetAdaptersInfo = (PtrGetAdaptersInfo)iphlpapi.resolve("GetAdaptersInfo"); ptrGetAdaptersAddresses = (PtrGetAdaptersAddresses)iphlpapi.resolve("GetAdaptersAddresses"); ptrGetNetworkParams = (PtrGetNetworkParams)iphlpapi.resolve("GetNetworkParams"); } + done = true; } } -- cgit v0.12 From 1e8479b2aa781e6ce3fadf01294023fbc6ddbc22 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 7 Oct 2011 14:45:47 +0200 Subject: don't lock the global mutex if there is nothing to protect according to Thiago, setting the pointer with the same values *is* thread-safe Merge-request: 2655 Reviewed-by: Jan-Arve Saether --- src/corelib/kernel/qeventdispatcher_win.cpp | 6 ------ src/gui/dialogs/qfiledialog_win.cpp | 17 ----------------- src/network/kernel/qhostinfo_win.cpp | 20 ++++++++------------ src/plugins/bearer/nativewifi/main.cpp | 14 +------------- 4 files changed, 9 insertions(+), 48 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 365b28e..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 -#include QT_BEGIN_NAMESPACE @@ -322,11 +321,6 @@ static void resolveTimerAPI() { static bool triedResolve = false; if (!triedResolve) { -#ifndef QT_NO_THREAD - QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve)); - if (triedResolve) - return; -#endif #ifndef Q_OS_WINCE QSystemLibrary library(QLatin1String("Mmtimer")); #else diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/gui/dialogs/qfiledialog_win.cpp index 45f6164..32dbe4f 100644 --- a/src/gui/dialogs/qfiledialog_win.cpp +++ b/src/gui/dialogs/qfiledialog_win.cpp @@ -55,10 +55,6 @@ #include #include "qfiledialog_win_p.h" -#ifndef QT_NO_THREAD -# include -#endif - #ifdef Q_WS_WINCE #include bool qt_priv_ptr_valid = false; @@ -83,20 +79,7 @@ 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 - #if !defined(Q_WS_WINCE) QSystemLibrary lib(QLatin1String("shell32")); ptrSHBrowseForFolder = (PtrSHBrowseForFolder)lib.resolve("SHBrowseForFolderW"); diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp index 03e72c4..1cbf350 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 #include -#include #include -#include QT_BEGIN_NAMESPACE @@ -84,6 +82,10 @@ 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) QSystemLibrary ws2lib(QLatin1String("ws2_32")); #else @@ -94,6 +96,8 @@ static void resolveLibrary() local_freeaddrinfo = (freeaddrinfoProto)ws2lib.resolve("freeaddrinfo"); local_getnameinfo = (getnameinfoProto)ws2lib.resolve("getnameinfo"); } + + triedResolve = true; } #if defined(Q_OS_WINCE) @@ -103,21 +107,13 @@ 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/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp index cbdfd99..d279631 100644 --- a/src/plugins/bearer/nativewifi/main.cpp +++ b/src/plugins/bearer/nativewifi/main.cpp @@ -42,30 +42,18 @@ #include "qnativewifiengine.h" #include "platformdefs.h" -#include -#include #include #include -#include - #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) - return; - QSystemLibrary wlanapi(QLatin1String("wlanapi")); if (wlanapi.load()) { local_WlanOpenHandle = (WlanOpenHandleProto) -- cgit v0.12 From 919e75fb1bad3c3a399e072c52e850c0df5b2f71 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Mon, 10 Oct 2011 08:09:06 +0200 Subject: Fix regression introduced by 1bfef526ef3d1deb7cf0f11dc1880f33937a85ac Reviewed-by: Trustme --- src/corelib/io/qfilesystemengine_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 218cf20..338552c 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -256,7 +256,7 @@ static bool resolveUNCLibs() #endif #if !defined(Q_OS_WINCE) - QSystemLibrary netapi32(QLatin1String("kernel32")); + QSystemLibrary netapi32(QLatin1String("Netapi32")); if (netapi32.load()) { ptrNetShareEnum = (PtrNetShareEnum)netapi32.resolve("NetShareEnum"); ptrNetApiBufferFree = (PtrNetApiBufferFree)netapi32.resolve("NetApiBufferFree"); -- cgit v0.12 From ecd78168271cfe71715e074a50752712f4aa3229 Mon Sep 17 00:00:00 2001 From: Tero Ahola Date: Mon, 10 Oct 2011 17:02:33 +0200 Subject: Fixed resource leak when setting QProgressBar style sheet Task-number: QTBUG-19110 Merge-request: 2687 Reviewed-by: Frederik Gladhorn --- src/gui/styles/qwindowsstyle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); } } } -- cgit v0.12 From 4c64464ddf63ed89603ad759ffb68c6f298edd26 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 13 Oct 2011 14:37:36 +0200 Subject: Fix regression in ListView This reverts commit d91a8f3a5dbcf3e4c4c0afb28463b25e192b00e4 and introduces a minimal fix for the original crash report. Task-number: QTBUG-21433 Reviewed-by: gabriel --- src/gui/itemviews/qlistview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index a0955d2..01a9eec 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 } } -- cgit v0.12 From b3eca5777543fb6fc97e025b03fe07ed9541c0a5 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Fri, 14 Oct 2011 11:47:58 +0200 Subject: Fix bug in QStringToBSTR. Use the same implementation as found in ActiveQt, which Volker suggested. Task-number: QTBUG-11083 --- src/gui/accessible/qaccessible_win.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index c1bb54b..f404535 100644 --- a/src/gui/accessible/qaccessible_win.cpp +++ b/src/gui/accessible/qaccessible_win.cpp @@ -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()); } /* -- cgit v0.12