Skip to content

Commit b30406b

Browse files
committed
Drop workarounds for Qt<6.9
1 parent 5d177ee commit b30406b

13 files changed

Lines changed: 19 additions & 154 deletions

CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,8 @@ if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten" AND
163163
)
164164
endif()
165165

166-
if(QT_KNOWN_POLICY_QTP0001)
167-
qt_policy(SET QTP0001 NEW)
168-
endif()
169-
170-
if(QT_KNOWN_POLICY_QTP0004)
171-
qt_policy(SET QTP0004 OLD)
172-
endif()
166+
qt_policy(SET QTP0001 NEW)
167+
qt_policy(SET QTP0004 OLD)
173168

174169
message("Using Qt version ${Qt6_VERSION}")
175170
add_definitions(-DQT_DEPRECATED_WARNINGS)

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mz_target_handle_warnings(mozillavpn)
1111

1212
find_package(Qt6 REQUIRED COMPONENTS Svg)
1313
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.10.0)
14+
set(QT_NO_PRIVATE_MODULE_WARNING ON)
1415
find_package(Qt6 REQUIRED COMPONENTS GuiPrivate QmlPrivate)
1516
endif()
1617

src/cmake/android.cmake

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ set_property(TARGET mozillavpn PROPERTY QT_ANDROID_EXTRA_LIBS
6767
APPEND)
6868

6969

70-
if( ${Qt6_VERSION} VERSION_GREATER_EQUAL 6.4.0)
71-
set_property(TARGET mozillavpn PROPERTY QT_ANDROID_EXTRA_LIBS
70+
set_property(TARGET mozillavpn APPEND PROPERTY
71+
QT_ANDROID_EXTRA_LIBS
7272
${OPENSSL_LIBS_DIR}/libcrypto_3.so
73-
${OPENSSL_LIBS_DIR}/libssl_3.so
74-
APPEND)
75-
endif()
73+
${OPENSSL_LIBS_DIR}/libssl_3.so)
7674

7775
option(MZ_ANDROID_FOSS_BUILD "Build apk without google play services" OFF)
7876

src/cmake/linux.cmake

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ target_sources(mozillavpn PRIVATE
4343
)
4444

4545
# Resolving the parent window handle for the XDG desktop portal on Wayland
46-
# needs the Gui internal header files on Qt 6.5.0 and later. Otherwise it
47-
# only works for X11.
48-
if(Qt6_VERSION VERSION_GREATER_EQUAL 6.5.0)
49-
target_link_libraries(mozillavpn PRIVATE Qt6::GuiPrivate)
50-
endif()
46+
# needs the Gui internal header files on Qt 6.5.0 and later.
47+
target_link_libraries(mozillavpn PRIVATE Qt6::GuiPrivate)
5148

5249
if(NOT BUILD_FLATPAK)
5350
# Link to polkit

src/commands/commandui.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,6 @@ int CommandUI::run(QStringList& tokens) {
246246
vpn->initialize();
247247
logger.debug() << "VPN initialized";
248248

249-
// Prior to Qt 6.5, there was no default QML import path. We must set one.
250-
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
251-
engine->addImportPath("qrc:/");
252-
engine->addImportPath("qrc:/qt/qml");
253-
logger.debug() << "Added QML import paths";
254-
#endif
255249
QQuickImageProvider* provider = ImageProviderFactory::create(qApp);
256250
if (provider) {
257251
engine->addImageProvider(QString("app"), provider);
@@ -268,13 +262,8 @@ int CommandUI::run(QStringList& tokens) {
268262
I18nStrings::instance());
269263
logger.debug() << "Registered I18nStrings";
270264

271-
#if MZ_IOS && QT_VERSION < 0x060300
272-
QObject::connect(qApp, &QCoreApplication::aboutToQuit, vpn,
273-
&MozillaVPN::quit);
274-
#else
275265
QObject::connect(qApp, &QCoreApplication::aboutToQuit, vpn,
276266
[] { MozillaVPN::instance()->aboutToQuit(); });
277-
#endif
278267

279268
QObject::connect(
280269
qApp, &QGuiApplication::commitDataRequest, vpn,

src/mozillavpn.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,6 @@ void MozillaVPN::quit() {
148148
logger.debug() << "quit";
149149
TaskScheduler::forceDeleteTasks();
150150

151-
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 4)
152-
// Qt5Compat.GraphicalEffects makes the app crash on shutdown. Let's do a
153-
// quick exit. See: https://bugreports.qt.io/browse/QTBUG-100687
154-
// it is unknown when exactly this was fixed but apparently 6.2.4 is fine.
155-
156-
SettingsManager::instance()->sync();
157-
exit(0);
158-
#endif
159-
160151
qApp->quit();
161152
}
162153

src/networkrequest.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -211,37 +211,6 @@ void NetworkRequest::replyFinished() {
211211
return;
212212
}
213213

214-
#if QT_VERSION < 0x060400
215-
if (m_reply->error() == QNetworkReply::HostNotFoundError && isRedirect()) {
216-
QUrl brokenUrl = m_reply->url();
217-
218-
if (brokenUrl.host().isEmpty() && !m_redirectedUrl.isEmpty()) {
219-
QUrl url = m_redirectedUrl.resolved(brokenUrl);
220-
221-
# ifdef MZ_DEBUG
222-
// See https://bugreports.qt.io/browse/QTBUG-100651
223-
logger.debug()
224-
<< "QT6 redirect bug! The current URL is broken because it's not "
225-
"resolved using the latest HTTP redirection as base-URL";
226-
logger.debug() << "Broken URL:" << brokenUrl.toString();
227-
logger.debug() << "Latest redirected URL:" << m_redirectedUrl.toString();
228-
logger.debug() << "Final URL:" << url.toString();
229-
# endif
230-
231-
m_request = QNetworkRequest(url);
232-
m_request.setHeader(QNetworkRequest::ContentTypeHeader,
233-
"application/json");
234-
m_request.setAttribute(QNetworkRequest::RedirectPolicyAttribute,
235-
QNetworkRequest::NoLessSafeRedirectPolicy);
236-
237-
m_reply = nullptr;
238-
m_timer.stop();
239-
getResource();
240-
return;
241-
}
242-
}
243-
#endif
244-
245214
int status = statusCode();
246215
logger.debug() << "Network reply received - status:" << status
247216
<< "- expected:" << expectStatusString();
@@ -332,29 +301,7 @@ void NetworkRequest::handleHeaderReceived() {
332301
}
333302

334303
void NetworkRequest::handleRedirect(const QUrl& redirectUrl) {
335-
#if QT_VERSION < 0x060400
336-
if (redirectUrl.host().isEmpty()) {
337-
# ifdef MZ_DEBUG
338-
// See https://bugreports.qt.io/browse/QTBUG-100651
339-
logger.debug()
340-
<< "QT6 redirect bug! The redirected URL is broken because it's not "
341-
"resolved using the previous HTTP redirection as base-URL";
342-
logger.debug() << "Broken URL:" << redirectUrl.toString();
343-
logger.debug() << "Latest redirected URL:" << m_redirectedUrl.toString();
344-
# endif
345-
346-
if (m_redirectedUrl.isEmpty()) {
347-
m_redirectedUrl = url().resolved(redirectUrl);
348-
} else {
349-
m_redirectedUrl = m_redirectedUrl.resolved(redirectUrl);
350-
}
351-
} else {
352-
m_redirectedUrl = redirectUrl;
353-
}
354-
emit requestRedirected(this, m_redirectedUrl);
355-
#else
356304
emit requestRedirected(this, redirectUrl);
357-
#endif
358305
}
359306

360307
void NetworkRequest::timeout() {

src/networkwatcher.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,10 @@ void NetworkWatcher::initialize() {
9191
m_impl->start();
9292
}
9393

94-
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
9594
// This call creates an instance of QNetworkInformation which can be used
9695
// later on to check other network related attributes such as network type, or
9796
// whether or not the network is behind captive portal.
9897
QNetworkInformation::loadDefaultBackend();
99-
#endif
10098

10199
connect(settingsHolder, &SettingsHolder::unsecuredNetworkAlertChanged, this,
102100
&NetworkWatcher::settingsChanged);

src/platforms/linux/linuxutils.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,5 @@ QString LinuxUtils::desktopFileId(const QString& path) {
132132
return path.mid(index).replace('/', '-');
133133
}
134134

135-
// Workaround for QTBUG-108822 by manually registering QDBusObjectPath with the
136-
// D-Bus meta-type system, otherwise we are unable to connect to some signals.
137-
#if QT_VERSION < 0x060403
138-
class QtbugRegistrationProxy {
139-
public:
140-
QtbugRegistrationProxy() { qDBusRegisterMetaType<QDBusObjectPath>(); }
141-
};
142-
143-
static QtbugRegistrationProxy s_qtbugRegistrationProxy;
144-
#endif
145-
146135
// Ensure that the D-Bus custom types are registered.
147136
static DBusMetatypeRegistrationProxy s_dbusMetatypeProxy;

src/platforms/linux/xdgportal.cpp

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@
1111
#include <QProcessEnvironment>
1212
#include <QRandomGenerator>
1313

14-
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
15-
# include <private/qdesktopunixservices_p.h>
16-
# include <private/qguiapplication_p.h>
17-
# include <qpa/qplatformintegration.h>
18-
#elif QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
19-
# include <private/qgenericunixservices_p.h>
20-
# include <private/qguiapplication_p.h>
21-
# include <qpa/qplatformintegration.h>
22-
#else
23-
# include <QGuiApplication>
24-
# include <QWindow>
25-
#endif
14+
#include <private/qdesktopunixservices_p.h>
15+
#include <private/qguiapplication_p.h>
16+
#include <qpa/qplatformintegration.h>
2617

2718
#include "dbustypes.h"
2819
#include "leakdetector.h"
@@ -116,24 +107,12 @@ QString XdgPortal::parentWindow() {
116107
if (!holder->hasWindow()) {
117108
return QString("");
118109
}
119-
#if QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)
110+
120111
QDesktopUnixServices* services = dynamic_cast<QDesktopUnixServices*>(
121112
QGuiApplicationPrivate::platformIntegration()->services());
122113
if (services != nullptr) {
123114
return services->portalWindowIdentifier(holder->window());
124115
}
125-
#elif QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
126-
QGenericUnixServices* services = dynamic_cast<QGenericUnixServices*>(
127-
QGuiApplicationPrivate::platformIntegration()->services());
128-
if (services != nullptr) {
129-
return services->portalWindowIdentifier(holder->window());
130-
}
131-
#else
132-
// X11 is the only platform that we can get a window handle on prior to 6.5.0
133-
if (QGuiApplication::platformName() == "xcb") {
134-
return "x11:" + QString::number(holder->window()->winId(), 16);
135-
}
136-
#endif
137116

138117
// Otherwise, we don't support this windowing system.
139118
return QString("");
@@ -251,14 +230,14 @@ void XdgPortal::setupAppScope(const QString& appId) {
251230
// Qt 6.8 introduced a bug where using QDBusConnection::sessionBus() before
252231
// QCoreApplication is created will silently break D-Bus signal connections.
253232
// To workaround this, spin up a separate, standalone bus for these steps.
254-
#if (QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)) && \
255-
(QT_VERSION < QT_VERSION_CHECK(6, 9, 2))
233+
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 2)
256234
QString busName = QString("%1-appid-scope-helper").arg(appId);
257235
QDBusConnection bus =
258236
QDBusConnection::connectToBus(QDBusConnection::SessionBus, busName);
259237
auto guard =
260238
qScopeGuard([busName]() { QDBusConnection::disconnectFromBus(busName); });
261239
#else
240+
262241
// If the XDG Registry portal exists, use it to advertise our application ID.
263242
// This is the right tool to use, but it's also very new.
264243
QDBusInterface xdgRegistry(XDG_PORTAL_SERVICE, XDG_PORTAL_PATH,

0 commit comments

Comments
 (0)