[glibmm] Use std::unique_lock::unlock() instead of release()
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] Use std::unique_lock::unlock() instead of release()
- Date: Sat, 28 Nov 2015 10:01:12 +0000 (UTC)
commit c7d7d5f169103b2d16527c52a95a5dc78e216da6
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date: Sat Nov 28 10:57:39 2015 +0100
Use std::unique_lock::unlock() instead of release()
* glib/blibmm/main.cc:
* gio/src/application.ccg: Glib::Threads::Mutex::Lock::release() should have
been replaced by std::unique_lock::unlock(). std::unique_lock::release() does
not unlock the mutex. Bug #757674.
gio/src/application.ccg | 38 +++++++++++++++++++-------------------
glib/glibmm/main.cc | 6 +++---
2 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/gio/src/application.ccg b/gio/src/application.ccg
index 26bcb9e..9fb5866 100644
--- a/gio/src/application.ccg
+++ b/gio/src/application.ccg
@@ -1,5 +1,3 @@
-// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
-
/* Copyright (C) 2007 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
@@ -232,14 +230,14 @@ gboolean Application_option_arg_callback(const gchar* option_name, const gchar*
if (option_arg->is_filename_option())
{
const auto the_slot = option_arg->get_slot_filename();
- lock.release();
+ lock.unlock();
const std::string cpp_value(value ? value : "");
return (*the_slot)(cpp_option_name, cpp_value, has_value);
}
else
{
const auto the_slot = option_arg->get_slot_string();
- lock.release();
+ lock.unlock();
const Glib::ustring cpp_value(value ? value : "");
return (*the_slot)(cpp_option_name, cpp_value, has_value);
}
@@ -395,14 +393,15 @@ void Application::add_main_option_entry(
gchar short_name, const Glib::ustring& description,
const Glib::ustring& arg_description, int flags)
{
- std::unique_lock<std::mutex> lock(option_arg_callback_data_mutex);
- OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
- if (iterFind != option_arg_callback_data.end())
- return; // Ignore duplicates
+ {
+ std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex);
+ OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
+ if (iterFind != option_arg_callback_data.end())
+ return; // Ignore duplicates
- auto callback_data = new OptionArgCallbackData(this, short_name, slot);
- option_arg_callback_data[long_name] = callback_data;
- lock.release();
+ auto callback_data = new OptionArgCallbackData(this, short_name, slot);
+ option_arg_callback_data[long_name] = callback_data;
+ } // option_arg_callback_data_mutex.unlock()
add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name,
description, arg_description, flags & ~Glib::OptionEntry::FLAG_FILENAME);
@@ -413,14 +412,15 @@ void Application::add_main_option_entry_filename(
gchar short_name, const Glib::ustring& description,
const Glib::ustring& arg_description, int flags)
{
- std::unique_lock<std::mutex> lock(option_arg_callback_data_mutex);
- OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
- if (iterFind != option_arg_callback_data.end())
- return; // Ignore duplicates
-
- auto callback_data = new OptionArgCallbackData(this, short_name, slot);
- option_arg_callback_data[long_name] = callback_data;
- lock.release();
+ {
+ std::lock_guard<std::mutex> lock(option_arg_callback_data_mutex);
+ OptionArgCallbackDataMap::iterator iterFind = option_arg_callback_data.find(long_name);
+ if (iterFind != option_arg_callback_data.end())
+ return; // Ignore duplicates
+
+ auto callback_data = new OptionArgCallbackData(this, short_name, slot);
+ option_arg_callback_data[long_name] = callback_data;
+ } // option_arg_callback_data_mutex.unlock()
add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name,
description, arg_description, flags | Glib::OptionEntry::FLAG_FILENAME);
diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc
index ebc3dc5..d44d71b 100644
--- a/glib/glibmm/main.cc
+++ b/glib/glibmm/main.cc
@@ -184,7 +184,7 @@ void SourceCallbackData::destroy_notify_callback(void* data)
{
// No other reference exists to the wrapper. Delete it!
extra_source_data.erase(self->wrapper);
- lock.release();
+ lock.unlock();
Glib::Source::destroy_notify_callback(self->wrapper);
}
}
@@ -898,11 +898,11 @@ void Source::unreference() const
// extra_source_data[this].keep_wrapper was > 1.
// Delete the wrapper!
extra_source_data.erase(this);
- lock.release();
+ lock.unlock();
destroy_notify_callback(const_cast<Source*>(this));
}
else
- lock.release();
+ lock.unlock();
// Drop the one and only GSource reference held by the C++ wrapper.
// If the GSource instance is attached to a main context, the GMainContext
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]