[Spice-commits] vdagent/desktop_layout.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 22 18:34:31 UTC 2020
vdagent/desktop_layout.cpp | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
New commits:
commit d9aeb42bce979977dc49a06ff7edee828427a721
Author: Frediano Ziglio <freddy77 at gmail.com>
Date: Fri May 22 12:02:46 2020 +0100
desktop_layout: Use MutexLocker for lock/unlock
Reduce code and avoids to forget to unlock() in the future.
Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
Acked-by: Kevin Pouget <kpouget at redhat.com>
diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index a10d898..3a36d22 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -56,9 +56,8 @@ void DesktopLayout::get_displays()
DWORD dev_id = 0;
bool attached;
- lock();
+ MutexLocker lock(_mutex);
if (!consistent_displays()) {
- unlock();
return;
}
_display_config->update_config_path();
@@ -94,7 +93,6 @@ void DesktopLayout::get_displays()
_display_config->update_monitor_config(dev_info.DeviceName, _displays[display_id], &mode);
}
normalize_displays_pos();
- unlock();
}
DisplayMode * DesktopLayout::get_primary_display()
@@ -120,9 +118,8 @@ void DesktopLayout::set_displays()
DWORD display_id = 0;
int dev_sets = 0;
- lock();
+ MutexLocker lock(_mutex);
if (!consistent_displays()) {
- unlock();
return;
}
_display_config->update_config_path();
@@ -171,7 +168,6 @@ void DesktopLayout::set_displays()
_display_config->update_display_settings();
normalize_displays_pos();
}
- unlock();
}
void DesktopLayout::set_position_configurable(bool flag) {
@@ -236,7 +232,7 @@ bool DesktopLayout::consistent_displays()
void DesktopLayout::clean_displays()
{
- lock();
+ MutexLocker lock(_mutex);
_total_width = 0;
_total_height = 0;
while (!_displays.empty()) {
@@ -244,7 +240,6 @@ void DesktopLayout::clean_displays()
_displays.pop_back();
delete mode;
}
- unlock();
}
bool DesktopLayout::is_attached(LPCTSTR dev_name)
More information about the Spice-commits
mailing list