diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index d09c6789b75..60aae511001 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -635,11 +635,10 @@ void QVncServer::newConnection() void QVncServer::discardClient(QVncClient *client) { clients.removeOne(client); + qvnc_screen->disableClientCursor(client); client->deleteLater(); - if (clients.isEmpty()) { - qvnc_screen->disableClientCursor(client); + if (clients.isEmpty()) qvnc_screen->setPowerState(QPlatformScreen::PowerStateOff); - } } inline QImage QVncServer::screenImage() const diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp index eb8241138e0..c67e5a00739 100644 --- a/src/plugins/platforms/vnc/qvncscreen.cpp +++ b/src/plugins/platforms/vnc/qvncscreen.cpp @@ -113,9 +113,10 @@ void QVncScreen::disableClientCursor(QVncClient *client) if (clientCount == 0) { delete clientCursor; clientCursor = nullptr; - } - mCursor = new QFbCursor(this); + if (mCursor == nullptr) + mCursor = new QFbCursor(this); + } #else Q_UNUSED(client); #endif