From c3226bd5cc6bf009d2fb3c233a09f3ef5cf618e9 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 25 Mar 2019 12:40:36 +0100 Subject: configure: add linker flags for xkbcommon* when pkg-config not present Without this, xkbcommon feature would not be detected even if all xkbcommon dev libs are present. Change-Id: Ic247461dda9e7ddfed547708cccaad88f123903b Reviewed-by: Joerg Bornemann --- src/gui/configure.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index e4f25ab313..6fdcd562a7 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -764,7 +764,8 @@ }, "headers": [ "xkbcommon/xkbcommon.h" ], "sources": [ - { "type": "pkgConfig", "args": "xkbcommon >= 0.5.0" } + { "type": "pkgConfig", "args": "xkbcommon >= 0.5.0" }, + "-lxkbcommon" ] }, "xkbcommon_x11": { @@ -774,7 +775,8 @@ }, "headers": [ "xkbcommon/xkbcommon-x11.h" ], "sources": [ - { "type": "pkgConfig", "args": "xkbcommon-x11" } + { "type": "pkgConfig", "args": "xkbcommon-x11" }, + "-lxkbcommon -lxkbcommon-x11" ] }, "xrender": { -- cgit v1.2.3 From 243c8403903781a28832e0bf34ce962058300e99 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Tue, 26 Mar 2019 00:02:22 +0100 Subject: Drag'n'Drop: fix dnd regression DragEnter events always should start with the default state, which is accepted = false. This was a copy-and-paste error introduced by f8944a7f07112c85dc4f66848cabb490514cd28e. Fixes: QTBUG-73977 Change-Id: I34b3ea97c9b4f4fc040a9e6f1befd6124533361d Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qwidgetwindow.cpp | 2 - .../kernel/qwidget_window/tst_qwidget_window.cpp | 75 ++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index e9b749d7c2..fbc71cd0ea 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -878,8 +878,6 @@ void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos())); QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers()); - translated.setDropAction(event->dropAction()); - translated.setAccepted(event->isAccepted()); QGuiApplication::forwardEvent(m_dragTarget, &translated, event); event->setAccepted(translated.isAccepted()); event->setDropAction(translated.dropAction()); diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index 431d6ba960..8b558aa56f 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -46,6 +46,9 @@ #include #include #include +#include +#include +#include #include @@ -87,6 +90,7 @@ private slots: #if QT_CONFIG(draganddrop) void tst_dnd(); void tst_dnd_events(); + void tst_dnd_propagation(); #endif void tst_qtbug35600(); @@ -744,6 +748,77 @@ void tst_QWidget_window::tst_dnd_events() QCOMPARE(dndWidget._dndEvents, expectedDndEvents); } + +class DropTarget : public QWidget +{ +public: + explicit DropTarget() + { + setAcceptDrops(true); + + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + auto width = availableGeometry.width() / 6; + auto height = availableGeometry.height() / 4; + + setGeometry(availableGeometry.x() + 200, availableGeometry.y() + 200, width, height); + + QLabel *label = new QLabel(QStringLiteral("Test"), this); + label->setGeometry(40, 40, 60, 60); + label->setAcceptDrops(true); + } + + void dragEnterEvent(QDragEnterEvent *event) override + { + event->accept(); + mDndEvents.append("enter "); + } + + void dragMoveEvent(QDragMoveEvent *event) override + { + event->acceptProposedAction(); + } + + void dragLeaveEvent(QDragLeaveEvent *) override + { + mDndEvents.append("leave "); + } + + void dropEvent(QDropEvent *event) override + { + event->accept(); + mDndEvents.append("drop "); + } + + QString mDndEvents; +}; + +void tst_QWidget_window::tst_dnd_propagation() +{ + QMimeData mimeData; + mimeData.setText(QLatin1String("testmimetext")); + + DropTarget target; + target.show(); + QVERIFY(QTest::qWaitForWindowActive(&target)); + + Qt::DropActions supportedActions = Qt::DropAction::CopyAction; + QWindow *window = target.windowHandle(); + + auto posInsideDropTarget = QHighDpi::toNativePixels(QPoint(20, 20), window->screen()); + auto posInsideLabel = QHighDpi::toNativePixels(QPoint(60, 60), window->screen()); + + // Enter DropTarget. + QWindowSystemInterface::handleDrag(window, &mimeData, posInsideDropTarget, supportedActions, 0, 0); + // Enter QLabel. This will propagate because default QLabel does + // not accept the drop event in dragEnterEvent(). + QWindowSystemInterface::handleDrag(window, &mimeData, posInsideLabel, supportedActions, 0, 0); + // Drop on QLabel. DropTarget will get dropEvent(), because it accepted the event. + QWindowSystemInterface::handleDrop(window, &mimeData, posInsideLabel, supportedActions, 0, 0); + + QGuiApplication::processEvents(); + + QCOMPARE(target.mDndEvents, "enter leave enter drop "); +} #endif void tst_QWidget_window::tst_qtbug35600() -- cgit v1.2.3 From ae5db669e8989fe793949346d8061c67e5ec31cd Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 28 Mar 2019 10:12:12 +0100 Subject: Doc: Improve WinTab license information Do not categorize the license anymore as 'Public Domain', because the actual text is not explicit on whether it allows modifications. Instead show the original license text. Also remove the Homepage link, which now just displays (arguably outdated) information about patents. Finally, do not misuse the "Version" field for metadata information, use the newly introduced "PackageComment" field instead. [ChangeLog][Third-Party Code] Changed classification of the wintab license from Public Domain to Custom. Fixes: QTBUG-74453 Change-Id: Ibae36be1deee3b9c498c45d03ed741c3d5ff630c Reviewed-by: Alex Blasche Reviewed-by: Lars Knoll --- src/3rdparty/wintab/LICENSE.txt | 2 ++ src/3rdparty/wintab/qt_attribution.json | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 src/3rdparty/wintab/LICENSE.txt diff --git a/src/3rdparty/wintab/LICENSE.txt b/src/3rdparty/wintab/LICENSE.txt new file mode 100644 index 0000000000..6c03ad2aff --- /dev/null +++ b/src/3rdparty/wintab/LICENSE.txt @@ -0,0 +1,2 @@ +The text and information contained in this file may be freely used, +copied, or distributed without compensation or licensing restrictions. diff --git a/src/3rdparty/wintab/qt_attribution.json b/src/3rdparty/wintab/qt_attribution.json index f0c9b49841..1b9c55552e 100644 --- a/src/3rdparty/wintab/qt_attribution.json +++ b/src/3rdparty/wintab/qt_attribution.json @@ -5,9 +5,9 @@ "QtUsage": "Used in the Qt platform plugin for Windows. Configure with -no-feature-tabletevent to avoid.", "Description": "Wintab is a de facto API for pointing devices on Windows.", - "Version": "Upstream no longer offers updates; treat as final", - "Homepage": "http://www.pointing.com/Wintab.html", - "License": "Public Domain", + "PackageComment": "Upstream http://www.pointing.com/Wintab.html no longer offers updates; treat as final", + "License": "Custom License", + "LicenseFile": "LICENSE.txt", "LicenseId": "NONE", "Copyright": "Copyright 1991-1998 by LCS/Telegraphics." } -- cgit v1.2.3 From a0b5d6e60f96359d88352e0b1c000678cdc80988 Mon Sep 17 00:00:00 2001 From: Jani Heikkinen Date: Thu, 4 Apr 2019 15:05:16 +0300 Subject: Revert "Let "qmake -install qinstall" set default permissions 0644 and 0755" This reverts commit 3cdf46059a668f588fe237aa881c300dd76cbf9e. It seems change is causing regression & is reverted now to be able to proceed with releases Task-number: QTBUG-74912 Change-Id: Ib2365b96ee98fbbcc8853cc7f8726c157c1913a7 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Joerg Bornemann --- qmake/main.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/qmake/main.cpp b/qmake/main.cpp index e5f7032554..a4ef79227b 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -260,25 +260,31 @@ static int installFile(const QString &source, const QString &target, bool exe = return 3; } - QFileDevice::Permissions targetPermissions = QFileDevice::ReadOwner | QFileDevice::WriteOwner - | QFileDevice::ReadUser | QFileDevice::WriteUser - | QFileDevice::ReadGroup | QFileDevice::ReadOther; if (exe) { - targetPermissions |= QFileDevice::ExeOwner | QFileDevice::ExeUser | - QFileDevice::ExeGroup | QFileDevice::ExeOther; - } - if (!targetFile.setPermissions(targetPermissions)) { - fprintf(stderr, "Error setting permissions on %s: %s\n", - qPrintable(target), qPrintable(targetFile.errorString())); - return 3; + if (!targetFile.setPermissions(sourceFile.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeUser | + QFileDevice::ExeGroup | QFileDevice::ExeOther)) { + fprintf(stderr, "Error setting execute permissions on %s: %s\n", + qPrintable(target), qPrintable(targetFile.errorString())); + return 3; + } } // Copy file times QString error; +#ifdef Q_OS_WIN + const QFile::Permissions permissions = targetFile.permissions(); + const bool readOnly = !(permissions & QFile::WriteUser); + if (readOnly) + targetFile.setPermissions(permissions | QFile::WriteUser); +#endif if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) { fprintf(stderr, "%s", qPrintable(error)); return 3; } +#ifdef Q_OS_WIN + if (readOnly) + targetFile.setPermissions(permissions); +#endif return 0; } -- cgit v1.2.3 From 82ad4be4a2e0c2bccb6cd8ea2440aefee4ec48ec Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 27 Mar 2019 17:01:40 +0000 Subject: Fix various uncommon cases in QTzTimeZonePrivate backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Includes a fixup for 03fadc26e7617aece89949bc7d0acf50f6f050a9, which removed the check on empty transition list, needed when no data are available. Ensured that such a data-free zone would in fact be noticed as invalid during init(). Fixed handling of times before the epoch (we still want to consult a POSIX rule, if that's all that's available) while ensuring we (as documented) ignore DST for such times. Fixed handling of large times (milliseconds since epoch outside int range) when looking up POSIX rules. Gave QTimeZonePrivate a YearRange enum (to be moved to QTimeZone once this merges up to dev) so as to eliminate a magic number (and avoid adding another). Moved year-munging in POSIX rules after the one early return, which doesn't need the year range. Added test-cases for the distant past/future (just checking UTC's offsets; SLES has a minimal version of the UTC data-file that triggers the bugs fixed here for them). Fixes: QTBUG-74666 Fixes: QTBUG-74550 Change-Id: Ief7b7e55c62cf11064700934f404b2fc283614e1 Reviewed-by: Tony Sarajärvi Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetime_p.h | 4 ++ src/corelib/tools/qtimezoneprivate_tz.cpp | 55 +++++++++++++--------- .../auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 7 ++- 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h index 4d30d4192b..b3d00745d0 100644 --- a/src/corelib/tools/qdatetime_p.h +++ b/src/corelib/tools/qdatetime_p.h @@ -140,6 +140,10 @@ public: // Inlined for its one caller in qdatetime.cpp inline void setUtcOffsetByTZ(qint64 atMSecsSinceEpoch); #endif // timezone + + // ### Qt 5.14: expose publicly in QDateTime + // The first and last years of which QDateTime can represent some part: + enum class YearRange : qint32 { First = -292275056, Last = +292278994 }; }; QT_END_NAMESPACE diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index f75a61977d..7d85bc077d 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -39,6 +39,7 @@ #include "qtimezone.h" #include "qtimezoneprivate_p.h" +#include "qdatetime_p.h" // ### Qt 5.14: remove once YearRange is on QDateTime #include #include @@ -520,19 +521,14 @@ PosixZone PosixZone::parse(const char *&pos, const char *end) static QVector calculatePosixTransitions(const QByteArray &posixRule, int startYear, int endYear, - int lastTranMSecs) + qint64 lastTranMSecs) { QVector result; - // Limit year by qint64 max size for msecs - if (startYear > 292278994) - startYear = 292278994; - if (endYear > 292278994) - endYear = 292278994; - // POSIX Format is like "TZ=CST6CDT,M3.2.0/2:00:00,M11.1.0/2:00:00" // i.e. "std offset dst [offset],start[/time],end[/time]" - // See the section about TZ at http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html + // See the section about TZ at + // http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html QList parts = posixRule.split(','); PosixZone stdZone, dstZone = PosixZone::invalid(); @@ -583,6 +579,13 @@ static QVector calculatePosixTransitions(const QByteArra else stdTime = QTime(2, 0, 0); + // Limit year to the range QDateTime can represent: + const int minYear = int(QDateTimePrivate::YearRange::First); + const int maxYear = int(QDateTimePrivate::YearRange::Last); + startYear = qBound(minYear, startYear, maxYear); + endYear = qBound(minYear, endYear, maxYear); + Q_ASSERT(startYear <= endYear); + for (int year = startYear; year <= endYear; ++year) { QTimeZonePrivate::Data dstData; QDateTime dst(calculatePosixDate(dstDateRule, year), dstTime, Qt::UTC); @@ -598,13 +601,16 @@ static QVector calculatePosixTransitions(const QByteArra stdData.standardTimeOffset = stdZone.offset; stdData.daylightTimeOffset = 0; stdData.abbreviation = stdZone.name; - // Part of the high year will overflow - if (year == 292278994 && (dstData.atMSecsSinceEpoch < 0 || stdData.atMSecsSinceEpoch < 0)) { + // Part of maxYear will overflow (likewise for minYear, below): + if (year == maxYear && (dstData.atMSecsSinceEpoch < 0 || stdData.atMSecsSinceEpoch < 0)) { if (dstData.atMSecsSinceEpoch > 0) { result << dstData; } else if (stdData.atMSecsSinceEpoch > 0) { result << stdData; } + } else if (year < 1970) { // We ignore DST before the epoch. + if (year > minYear || stdData.atMSecsSinceEpoch != QTimeZonePrivate::invalidMSecs()) + result << stdData; } else if (dst < std) { result << dstData << stdData; } else { @@ -794,6 +800,8 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId) tran.atMSecsSinceEpoch = tz_tran.tz_time * 1000; m_tranTimes.append(tran); } + if (m_tranTimes.isEmpty() && m_posixRule.isEmpty()) + return; // Invalid after all ! if (ianaId.isEmpty()) m_id = systemTimeZoneId(); @@ -954,22 +962,25 @@ QVector QTzTimeZonePrivate::getPosixTransitions(qint64 m QTimeZonePrivate::Data QTzTimeZonePrivate::data(qint64 forMSecsSinceEpoch) const { // If the required time is after the last transition (or there were none) - // and we have a POSIX rule then use it: - if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch) - && !m_posixRule.isEmpty() && forMSecsSinceEpoch >= 0) { + // and we have a POSIX rule, then use it: + if (!m_posixRule.isEmpty() + && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < forMSecsSinceEpoch)) { QVector posixTrans = getPosixTransitions(forMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [forMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { return at.atMSecsSinceEpoch <= forMSecsSinceEpoch; }); - if (it > posixTrans.cbegin()) { - QTimeZonePrivate::Data data = *--it; + // Use most recent, if any in the past; or the first if we have no other rules: + if (it > posixTrans.cbegin() || (m_tranTimes.isEmpty() && it < posixTrans.cend())) { + QTimeZonePrivate::Data data = *(it > posixTrans.cbegin() ? it - 1 : it); data.atMSecsSinceEpoch = forMSecsSinceEpoch; return data; } } + if (m_tranTimes.isEmpty()) // Only possible if !isValid() + return invalidData(); - // Otherwise, if we can find a valid tran, then use its rule: + // Otherwise, use the rule for the most recent or first transition: auto last = std::partition_point(m_tranTimes.cbegin(), m_tranTimes.cend(), [forMSecsSinceEpoch] (const QTzTransitionTime &at) { return at.atMSecsSinceEpoch <= forMSecsSinceEpoch; @@ -989,9 +1000,9 @@ bool QTzTimeZonePrivate::hasTransitions() const QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSinceEpoch) const { // If the required time is after the last transition (or there were none) - // and we have a POSIX rule then use it: - if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch) - && !m_posixRule.isEmpty() && afterMSecsSinceEpoch >= 0) { + // and we have a POSIX rule, then use it: + if (!m_posixRule.isEmpty() + && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < afterMSecsSinceEpoch)) { QVector posixTrans = getPosixTransitions(afterMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [afterMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { @@ -1012,9 +1023,9 @@ QTimeZonePrivate::Data QTzTimeZonePrivate::nextTransition(qint64 afterMSecsSince QTimeZonePrivate::Data QTzTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const { // If the required time is after the last transition (or there were none) - // and we have a POSIX rule then use it: - if ((m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch) - && !m_posixRule.isEmpty() && beforeMSecsSinceEpoch > 0) { + // and we have a POSIX rule, then use it: + if (!m_posixRule.isEmpty() + && (m_tranTimes.isEmpty() || m_tranTimes.last().atMSecsSinceEpoch < beforeMSecsSinceEpoch)) { QVector posixTrans = getPosixTransitions(beforeMSecsSinceEpoch); auto it = std::partition_point(posixTrans.cbegin(), posixTrans.cend(), [beforeMSecsSinceEpoch] (const QTimeZonePrivate::Data &at) { diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index eff9835776..bb6c48a2ed 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -539,8 +539,13 @@ void tst_QTimeZone::checkOffset_data() int year, month, day, hour, min, sec; int std, dst; } table[] = { - // Zone with no transitions (QTBUG-74614, when TZ backend uses minimalist data) + // Zone with no transitions (QTBUG-74614, QTBUG-74666, when TZ backend uses minimal data) { "Etc/UTC", "epoch", 1970, 1, 1, 0, 0, 0, 0, 0 }, + { "Etc/UTC", "pre_int32", 1901, 12, 13, 20, 45, 51, 0, 0 }, + { "Etc/UTC", "post_int32", 2038, 1, 19, 3, 14, 9, 0, 0 }, + { "Etc/UTC", "post_uint32", 2106, 2, 7, 6, 28, 17, 0, 0 }, + { "Etc/UTC", "initial", -292275056, 5, 16, 16, 47, 5, 0, 0 }, + { "Etc/UTC", "final", 292278994, 8, 17, 7, 12, 55, 0, 0 }, // Kiev: regression test for QTBUG-64122 (on MS): { "Europe/Kiev", "summer", 2017, 10, 27, 12, 0, 0, 2 * 3600, 3600 }, { "Europe/Kiev", "winter", 2017, 10, 29, 12, 0, 0, 2 * 3600, 0 } -- cgit v1.2.3 From 8eeb5150ed99914e252a84f1637f179e3de04659 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Fri, 5 Apr 2019 18:55:24 +0200 Subject: QDnsLookup: fix "Resolver functions not found" error on FreeBSD The current code only tries to load the required functions from LIBRESOLV_SO (if defined) and resolv, but on FreeBSD they are in libc: https://www.freebsd.org/cgi/man.cgi?query=res_query&sektion=3&apropos=0&manpath=freebsd This commit changes the code so that, after failing to load the non-existent libraries, it attempts to load the functions with dlsym() using the special handle RTLD_DEFAULT, which searches for the specified symbol in the loaded libraries. Task-number: QTBUG-74844 Change-Id: If97aaae233cabbfa01c30d26d9a7fb01ec3ff5c2 Reviewed-by: Joerg Bornemann Reviewed-by: Thiago Macieira --- src/network/kernel/kernel.pri | 6 ++++- src/network/kernel/qdnslookup_unix.cpp | 41 +++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index 11b80d59d5..d7a92a12eb 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -38,7 +38,11 @@ qtConfig(dnslookup) { } unix { - !integrity:qtConfig(dnslookup): SOURCES += kernel/qdnslookup_unix.cpp + !integrity:qtConfig(dnslookup) { + SOURCES += kernel/qdnslookup_unix.cpp + qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl + } + SOURCES += kernel/qhostinfo_unix.cpp qtConfig(linux-netlink): SOURCES += kernel/qnetworkinterface_linux.cpp diff --git a/src/network/kernel/qdnslookup_unix.cpp b/src/network/kernel/qdnslookup_unix.cpp index ce1ec6442a..ee7484ab35 100644 --- a/src/network/kernel/qdnslookup_unix.cpp +++ b/src/network/kernel/qdnslookup_unix.cpp @@ -59,6 +59,10 @@ # include #endif +#if defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen) +# include +#endif + #include QT_BEGIN_NAMESPACE @@ -87,6 +91,18 @@ struct QDnsLookupStateDeleter } }; +static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym) +{ + if (lib.isLoaded()) + return lib.resolve(sym); + +#if defined(RTLD_DEFAULT) && (defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen)) + return reinterpret_cast(dlsym(RTLD_DEFAULT, sym)); +#else + return nullptr; +#endif +} + static bool resolveLibraryInternal() { QLibrary lib; @@ -96,31 +112,30 @@ static bool resolveLibraryInternal() #endif { lib.setFileName(QLatin1String("resolv")); - if (!lib.load()) - return false; + lib.load(); } - local_dn_expand = dn_expand_proto(lib.resolve("__dn_expand")); + local_dn_expand = dn_expand_proto(resolveSymbol(lib, "__dn_expand")); if (!local_dn_expand) - local_dn_expand = dn_expand_proto(lib.resolve("dn_expand")); + local_dn_expand = dn_expand_proto(resolveSymbol(lib, "dn_expand")); - local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); + local_res_nclose = res_nclose_proto(resolveSymbol(lib, "__res_nclose")); if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_9_nclose")); + local_res_nclose = res_nclose_proto(resolveSymbol(lib, "res_9_nclose")); if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); + local_res_nclose = res_nclose_proto(resolveSymbol(lib, "res_nclose")); - local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); + local_res_ninit = res_ninit_proto(resolveSymbol(lib, "__res_ninit")); if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_9_ninit")); + local_res_ninit = res_ninit_proto(resolveSymbol(lib, "res_9_ninit")); if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); + local_res_ninit = res_ninit_proto(resolveSymbol(lib, "res_ninit")); - local_res_nquery = res_nquery_proto(lib.resolve("__res_nquery")); + local_res_nquery = res_nquery_proto(resolveSymbol(lib, "__res_nquery")); if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_9_nquery")); + local_res_nquery = res_nquery_proto(resolveSymbol(lib, "res_9_nquery")); if (!local_res_nquery) - local_res_nquery = res_nquery_proto(lib.resolve("res_nquery")); + local_res_nquery = res_nquery_proto(resolveSymbol(lib, "res_nquery")); return true; } -- cgit v1.2.3 From e199710d0ea804e4481042f41b91b5234540f5d5 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Sat, 6 Apr 2019 08:01:11 +0200 Subject: QHostInfo: use dlsym() with RTLD_DEFAULT in case libs cannot be loaded The current code only tries to load the required functions from LIBRESOLV_SO (if defined) and resolv, but on FreeBSD they are in libc: https://www.freebsd.org/cgi/man.cgi?query=res_query&sektion=3&apropos=0&manpath=freebsd This commit changes the code so that, after failing to load the non-existent libraries, it attempts to load the functions with dlsym() using the special handle RTLD_DEFAULT, which searches for the specified symbol in the loaded libraries. This is a follow-up to 8eeb5150ed99914e252a84f1637f179e3de04659. Change-Id: I19d90b0ca8703398bf4f5f4edd5ae31e346ef251 Reviewed-by: Thiago Macieira --- src/network/kernel/kernel.pri | 7 +++---- src/network/kernel/qhostinfo_unix.cpp | 33 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri index d7a92a12eb..7074fcd5eb 100644 --- a/src/network/kernel/kernel.pri +++ b/src/network/kernel/kernel.pri @@ -38,13 +38,12 @@ qtConfig(dnslookup) { } unix { - !integrity:qtConfig(dnslookup) { - SOURCES += kernel/qdnslookup_unix.cpp - qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl - } + !integrity:qtConfig(dnslookup): SOURCES += kernel/qdnslookup_unix.cpp SOURCES += kernel/qhostinfo_unix.cpp + qtConfig(dlopen): QMAKE_USE_PRIVATE += libdl + qtConfig(linux-netlink): SOURCES += kernel/qnetworkinterface_linux.cpp else: SOURCES += kernel/qnetworkinterface_unix.cpp } diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp index d22608e22f..e4810d68ee 100644 --- a/src/network/kernel/qhostinfo_unix.cpp +++ b/src/network/kernel/qhostinfo_unix.cpp @@ -66,6 +66,10 @@ # include #endif +#if defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen) +# include +#endif + QT_BEGIN_NAMESPACE // Almost always the same. If not, specify in qplatformdefs.h. @@ -115,6 +119,18 @@ struct LibResolv }; } +static QFunctionPointer resolveSymbol(QLibrary &lib, const char *sym) +{ + if (lib.isLoaded()) + return lib.resolve(sym); + +#if defined(RTLD_DEFAULT) && (defined(Q_OS_FREEBSD) || QT_CONFIG(dlopen)) + return reinterpret_cast(dlsym(RTLD_DEFAULT, sym)); +#else + return nullptr; +#endif +} + LibResolv::LibResolv() { QLibrary lib; @@ -124,31 +140,30 @@ LibResolv::LibResolv() #endif { lib.setFileName(QLatin1String("resolv")); - if (!lib.load()) - return; + lib.load(); } // res_ninit is required for localDomainName() - local_res_ninit = res_ninit_proto(lib.resolve("__res_ninit")); + local_res_ninit = res_ninit_proto(resolveSymbol(lib, "__res_ninit")); if (!local_res_ninit) - local_res_ninit = res_ninit_proto(lib.resolve("res_ninit")); + local_res_ninit = res_ninit_proto(resolveSymbol(lib, "res_ninit")); if (local_res_ninit) { // we must now find res_nclose - local_res_nclose = res_nclose_proto(lib.resolve("res_nclose")); + local_res_nclose = res_nclose_proto(resolveSymbol(lib, "res_nclose")); if (!local_res_nclose) - local_res_nclose = res_nclose_proto(lib.resolve("__res_nclose")); + local_res_nclose = res_nclose_proto(resolveSymbol(lib, "__res_nclose")); if (!local_res_nclose) local_res_ninit = nullptr; } if (ReinitNecessary || !local_res_ninit) { - local_res_init = res_init_proto(lib.resolve("__res_init")); + local_res_init = res_init_proto(resolveSymbol(lib, "__res_init")); if (!local_res_init) - local_res_init = res_init_proto(lib.resolve("res_init")); + local_res_init = res_init_proto(resolveSymbol(lib, "res_init")); if (local_res_init && !local_res_ninit) { // if we can't get a thread-safe context, we have to use the global _res state - local_res = res_state_ptr(lib.resolve("_res")); + local_res = res_state_ptr(resolveSymbol(lib, "_res")); } } } -- cgit v1.2.3 From 6863262dedea84435b0cee9a071e271ac759522c Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sat, 6 Apr 2019 11:46:35 +0200 Subject: QUdpSocket: Add missing \since to docs QNetworkDatagram was introduced together with these methods in Qt 5.8 (commit 4da2dda2aa) Change-Id: I454c26ebf6f94988cada8ac9315db1d43a31a595 Reviewed-by: Thiago Macieira --- src/network/socket/qudpsocket.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp index 85c4f4cbfd..0e3d516535 100644 --- a/src/network/socket/qudpsocket.cpp +++ b/src/network/socket/qudpsocket.cpp @@ -381,6 +381,7 @@ qint64 QUdpSocket::writeDatagram(const char *data, qint64 size, const QHostAddre */ /*! + \since 5.8 \overload Sends the datagram \a datagram to the host address and port numbers @@ -431,6 +432,8 @@ qint64 QUdpSocket::writeDatagram(const QNetworkDatagram &datagram) } /*! + \since 5.8 + Receives a datagram no larger than \a maxSize bytes and returns it in the QNetworkDatagram object, along with the sender's host address and port. If possible, this function will also try to determine the datagram's -- cgit v1.2.3 From a02a2a1e73206b3955438b38bb9311067ef04794 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Sat, 6 Apr 2019 11:54:24 +0200 Subject: QUdpSocket: Convert snippet to functor connect Change-Id: Ice210b979a1dd948cd8d95003bd50a4b71d91852 Reviewed-by: Thiago Macieira --- src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp index a98e31b10b..f6a28ce46c 100644 --- a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp +++ b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp @@ -54,8 +54,8 @@ void Server::initSocket() udpSocket = new QUdpSocket(this); udpSocket->bind(QHostAddress::LocalHost, 7755); - connect(udpSocket, SIGNAL(readyRead()), - this, SLOT(readPendingDatagrams())); + connect(udpSocket, &QUdpSocket::readyRead, + this, &Server::readPendingDatagrams); } void Server::readPendingDatagrams() -- cgit v1.2.3