From 066004e3e6e752b720506a3c697df9a4fd9d6e79 Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Thu, 18 Jul 2024 01:18:52 +0500
Subject: [PATCH 1/6] Fix warnings.

---
 source/host/ui/main_window.cc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/source/host/ui/main_window.cc b/source/host/ui/main_window.cc
index d308306ac..a72c3afc7 100644
--- a/source/host/ui/main_window.cc
+++ b/source/host/ui/main_window.cc
@@ -264,7 +264,7 @@ void MainWindow::onClientListChanged(const UserSessionAgent::ClientList& clients
 
         connect(notifier_, &NotifierWindow::sig_killSession, this, &MainWindow::onKillSession);
 
-        connect(notifier_, &NotifierWindow::sig_voiceChat, this, [=](bool enable)
+        connect(notifier_, &NotifierWindow::sig_voiceChat, this, [this](bool enable)
         {
             if (agent_proxy_)
                 agent_proxy_->setVoiceChat(enable);
@@ -275,7 +275,7 @@ void MainWindow::onClientListChanged(const UserSessionAgent::ClientList& clients
             // TODO
         });
 
-        connect(notifier_, &NotifierWindow::sig_lockMouse, this, [=](bool enable)
+        connect(notifier_, &NotifierWindow::sig_lockMouse, this, [this](bool enable)
         {
             if (agent_proxy_)
             {
@@ -287,7 +287,7 @@ void MainWindow::onClientListChanged(const UserSessionAgent::ClientList& clients
             }
         });
 
-        connect(notifier_, &NotifierWindow::sig_lockKeyboard, this, [=](bool enable)
+        connect(notifier_, &NotifierWindow::sig_lockKeyboard, this, [this](bool enable)
         {
             if (agent_proxy_)
             {
@@ -299,7 +299,7 @@ void MainWindow::onClientListChanged(const UserSessionAgent::ClientList& clients
             }
         });
 
-        connect(notifier_, &NotifierWindow::sig_pause, this, [=](bool enable)
+        connect(notifier_, &NotifierWindow::sig_pause, this, [this](bool enable)
         {
             if (agent_proxy_)
             {
@@ -633,7 +633,7 @@ void MainWindow::onSettings()
             {
                 QWinEventNotifier* process_watcher = new QWinEventNotifier(this);
 
-                connect(process_watcher, &QWinEventNotifier::activated, this, [=]
+                connect(process_watcher, &QWinEventNotifier::activated, this, [this, process_watcher]
                 {
                     process_watcher->deleteLater();
                     ui.action_settings->setEnabled(true);

From 65f1cba3687ca5b1aa48faffe35e1a2e9869f521 Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Thu, 18 Jul 2024 01:19:36 +0500
Subject: [PATCH 2/6] Fix pressed Shift key detection.

---
 source/host/ui/config_dialog.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/host/ui/config_dialog.cc b/source/host/ui/config_dialog.cc
index f3d23a0b6..d202be4f3 100644
--- a/source/host/ui/config_dialog.cc
+++ b/source/host/ui/config_dialog.cc
@@ -274,7 +274,7 @@ ConfigDialog::ConfigDialog(QWidget* parent)
         setConfigChanged(FROM_HERE, true);
     });
 
-    ui.tab_bar->setTabVisible(4, QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier));
+    ui.tab_bar->setTabVisible(4, QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier));
 
     //---------------------------------------------------------------------------------------------
     // Other

From c647cced92478a1635f20f235760143dda09866f Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Sun, 1 Sep 2024 00:16:01 +0500
Subject: [PATCH 3/6] Fix crash when previous connection with host ID already
 exists.

---
 source/router/server.cc | 45 +++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/source/router/server.cc b/source/router/server.cc
index e198f4425..bd9276c9b 100644
--- a/source/router/server.cc
+++ b/source/router/server.cc
@@ -276,27 +276,46 @@ bool Server::stopSession(Session::SessionId session_id)
 //--------------------------------------------------------------------------------------------------
 void Server::onHostSessionWithId(SessionHost* session)
 {
+    if (!session)
+    {
+        LOG(LS_ERROR) << "Invalid session pointer";
+        return;
+    }
+
     for (auto it = sessions_.begin(); it != sessions_.end();)
     {
-        if (it->get()->sessionType() == proto::ROUTER_SESSION_HOST)
+        Session* other_session_ptr = it->get();
+
+        if (!other_session_ptr || other_session_ptr->sessionType() != proto::ROUTER_SESSION_HOST)
+        {
+            ++it;
+            continue;
+        }
+
+        SessionHost* other_session = reinterpret_cast<SessionHost*>(other_session_ptr);
+        if (other_session == session)
+        {
+            ++it;
+            continue;
+        }
+
+        bool is_found = false;
+
+        for (const auto& host_id : session->hostIdList())
         {
-            SessionHost* other_session = reinterpret_cast<SessionHost*>(it->get());
-            if (other_session != session)
+            if (other_session->hasHostId(host_id))
             {
-                for (const auto& host_id : session->hostIdList())
-                {
-                    if (other_session->hasHostId(host_id))
-                    {
-                        LOG(LS_INFO) << "Detected previous connection with ID " << host_id;
+                LOG(LS_INFO) << "Detected previous connection with ID " << host_id;
 
-                        it = sessions_.erase(it);
-                        continue;
-                    }
-                }
+                is_found = true;
+                break;
             }
         }
 
-        ++it;
+        if (is_found)
+            it = sessions_.erase(it);
+        else
+            ++it;
     }
 }
 

From 3d91657d582226dfac5e3db109fdb67f7b2c5008 Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Mon, 23 Sep 2024 13:51:39 +0500
Subject: [PATCH 4/6] Disable LTO for Linux.

---
 source/CMakeLists.txt | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 2df6a0d7f..b0c7b28de 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -160,10 +160,14 @@ endif()
 check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT error)
 
 if (IPO_SUPPORTED)
-    message(STATUS "IPO/LTO supported")
+    if (LINUX)
+        message(STATUS IPO/LTO supported but disabled for Linux"
+    else()
+        message(STATUS "IPO/LTO supported")
 
-    # Enable link-time code generatation.
-    set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+        # Enable link-time code generatation.
+        set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
+    endif()
 else()
     message(STATUS "IPO/LTO not supported")
 endif()

From 09bd28048db39362c31aa739aed77b5d16162ba6 Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Mon, 23 Sep 2024 13:59:00 +0500
Subject: [PATCH 5/6] Fix typo.

---
 source/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index b0c7b28de..457faaa47 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -161,7 +161,7 @@ check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT error)
 
 if (IPO_SUPPORTED)
     if (LINUX)
-        message(STATUS IPO/LTO supported but disabled for Linux"
+        message(STATUS IPO/LTO supported but disabled for Linux")
     else()
         message(STATUS "IPO/LTO supported")
 

From fa6ef536a895dbcc8a76b6425a6faa4b8afcd71a Mon Sep 17 00:00:00 2001
From: Dmitry Chapyshev <dmitry@aspia.ru>
Date: Mon, 23 Sep 2024 14:04:25 +0500
Subject: [PATCH 6/6] Fix typo.

---
 source/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 457faaa47..568a4090c 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -161,7 +161,7 @@ check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT error)
 
 if (IPO_SUPPORTED)
     if (LINUX)
-        message(STATUS IPO/LTO supported but disabled for Linux")
+        message(STATUS "IPO/LTO supported but disabled for Linux")
     else()
         message(STATUS "IPO/LTO supported")