From 26352ee9ca8aec56b1a448dbaac0cc2f68701ff7 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 18 Dec 2021 13:01:01 +0100 Subject: [PATCH] Add connected socket check Fix WinMonitorStats member order --- ScreenPlay/src/sdkconnection.cpp | 4 ++++ .../inc/public/ScreenPlayUtil/util.h | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ScreenPlay/src/sdkconnection.cpp b/ScreenPlay/src/sdkconnection.cpp index bbadddc9..9e7d92a6 100644 --- a/ScreenPlay/src/sdkconnection.cpp +++ b/ScreenPlay/src/sdkconnection.cpp @@ -94,6 +94,10 @@ void ScreenPlay::SDKConnection::readyRead() */ bool ScreenPlay::SDKConnection::sendMessage(const QByteArray& message) { + if (!m_socket) { + qWarning() << "Unable to write to unconnected socket wit message: " << message; + return false; + } m_socket->write(message); return m_socket->waitForBytesWritten(); } diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h index 6005a462..0448a21a 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h @@ -54,12 +54,11 @@ namespace ScreenPlayUtil { #if defined(Q_OS_WIN) struct WinMonitorStats { - std::vector iMonitors; - std::vector hMonitors; - std::vector hdcMonitors; - std::vector rcMonitors; - std::vector scaleFactor; - std::vector> sizes; + + WinMonitorStats() + { + EnumDisplayMonitors(NULL, NULL, MonitorEnum, (LPARAM)this); + } static BOOL CALLBACK MonitorEnum(HMONITOR hMon, HDC hdc, LPRECT lprcMonitor, LPARAM pData) @@ -77,10 +76,19 @@ struct WinMonitorStats { pThis->hdcMonitors.push_back(hdc); pThis->rcMonitors.push_back(*lprcMonitor); pThis->iMonitors.push_back(pThis->hdcMonitors.size()); + + //qInfo() << std::abs(lprcMonitor->right - lprcMonitor->left) << std::abs(lprcMonitor->top - lprcMonitor->bottom); + return TRUE; } - WinMonitorStats() { EnumDisplayMonitors(0, 0, MonitorEnum, (LPARAM)this); } + std::vector iMonitors; + std::vector hMonitors; + std::vector hdcMonitors; + std::vector rcMonitors; + std::vector scaleFactor; + std::vector> sizes; + int index = 0; }; #endif QJsonArray fillArray(const QVector& items);