Restore "Do not create instance of QPlatformIntegration for invalid displays"
This patch is amended version of 67cc8fea10,
which was temporary reverted to simplify integration of conflicting
patches. What was amended:
- Dropped the factory interface. It is sufficiently clean to check for
QXcbConnection::isConnected().
Task-number: QTBUG-68859
Change-Id: I810897b3ea20e356fc4d62e6f01231fd287962dc
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
parent
5ac2b9ef59
commit
96218681f2
|
|
@ -195,14 +195,17 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char
|
|||
|
||||
const int numParameters = parameters.size();
|
||||
m_connections.reserve(1 + numParameters / 2);
|
||||
auto conn = new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName);
|
||||
if (conn->isConnected())
|
||||
m_connections << conn;
|
||||
else
|
||||
delete conn;
|
||||
|
||||
auto conn = new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, displayName);
|
||||
if (!conn->isConnected()) {
|
||||
delete conn;
|
||||
return;
|
||||
}
|
||||
m_connections << conn;
|
||||
|
||||
// ### Qt 6 (QTBUG-52408) remove this multi-connection code path
|
||||
for (int i = 0; i < numParameters - 1; i += 2) {
|
||||
qCDebug(lcQpaScreen) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
|
||||
qCDebug(lcQpaXcb) << "connecting to additional display: " << parameters.at(i) << parameters.at(i+1);
|
||||
QString display = parameters.at(i) + QLatin1Char(':') + parameters.at(i+1);
|
||||
conn = new QXcbConnection(m_nativeInterface.data(), m_canGrab, m_defaultVisualId, display.toLatin1().constData());
|
||||
if (conn->isConnected())
|
||||
|
|
@ -211,11 +214,6 @@ QXcbIntegration::QXcbIntegration(const QStringList ¶meters, int &argc, char
|
|||
delete conn;
|
||||
}
|
||||
|
||||
if (m_connections.isEmpty()) {
|
||||
qCritical("Could not connect to any X display.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
m_fontDatabase.reset(new QGenericUnixFontDatabase());
|
||||
|
||||
#if QT_CONFIG(xcb_native_painting)
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@ public:
|
|||
QPlatformTheme *createPlatformTheme(const QString &name) const override;
|
||||
QVariant styleHint(StyleHint hint) const override;
|
||||
|
||||
bool hasDefaultConnection() const { return !m_connections.isEmpty(); }
|
||||
QXcbConnection *defaultConnection() const { return m_connections.first(); }
|
||||
|
||||
QByteArray wmClass() const;
|
||||
|
|
|
|||
|
|
@ -52,10 +52,16 @@ public:
|
|||
|
||||
QPlatformIntegration* QXcbIntegrationPlugin::create(const QString& system, const QStringList& parameters, int &argc, char **argv)
|
||||
{
|
||||
if (!system.compare(QLatin1String("xcb"), Qt::CaseInsensitive))
|
||||
return new QXcbIntegration(parameters, argc, argv);
|
||||
if (!system.compare(QLatin1String("xcb"), Qt::CaseInsensitive)) {
|
||||
auto xcbIntegration = new QXcbIntegration(parameters, argc, argv);
|
||||
if (!xcbIntegration->hasDefaultConnection()) {
|
||||
delete xcbIntegration;
|
||||
return nullptr;
|
||||
}
|
||||
return xcbIntegration;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
Loading…
Reference in New Issue