scope_guard/modules: Rename scope_guard to ScopeGuard
Using pascal case for the class name keeps it more consistent with the majority of the other class names.
This commit is contained in:
parent
dd1de3efbf
commit
68dfd6aa3a
|
@ -5,14 +5,14 @@
|
||||||
namespace waybar::util {
|
namespace waybar::util {
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
class scope_guard {
|
class ScopeGuard {
|
||||||
public:
|
public:
|
||||||
explicit scope_guard(Func&& exit_function) : f{std::forward<Func>(exit_function)} {}
|
explicit ScopeGuard(Func&& exit_function) : f{std::forward<Func>(exit_function)} {}
|
||||||
scope_guard(const scope_guard&) = delete;
|
ScopeGuard(const ScopeGuard&) = delete;
|
||||||
scope_guard(scope_guard&&) = default;
|
ScopeGuard(ScopeGuard&&) = default;
|
||||||
scope_guard& operator=(const scope_guard&) = delete;
|
ScopeGuard& operator=(const ScopeGuard&) = delete;
|
||||||
scope_guard& operator=(scope_guard&&) = default;
|
ScopeGuard& operator=(ScopeGuard&&) = default;
|
||||||
~scope_guard() { f(); }
|
~ScopeGuard() { f(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Func f;
|
Func f;
|
||||||
|
|
|
@ -14,7 +14,7 @@ using GDBusManager = std::unique_ptr<GDBusObjectManager, void (*)(GDBusObjectMan
|
||||||
|
|
||||||
auto generateManager() -> GDBusManager {
|
auto generateManager() -> GDBusManager {
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ void waybar::modules::Custom::continuousWorker() {
|
||||||
}
|
}
|
||||||
thread_ = [this, cmd] {
|
thread_ = [this, cmd] {
|
||||||
char* buff = nullptr;
|
char* buff = nullptr;
|
||||||
waybar::util::scope_guard buff_deleter([buff]() {
|
waybar::util::ScopeGuard buff_deleter([buff]() {
|
||||||
if (buff) {
|
if (buff) {
|
||||||
free(buff);
|
free(buff);
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
|
||||||
}
|
}
|
||||||
|
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
|
||||||
}
|
}
|
||||||
|
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
@ -580,7 +580,7 @@ errorexit:
|
||||||
|
|
||||||
bool Mpris::handleToggle(GdkEventButton* const& e) {
|
bool Mpris::handleToggle(GdkEventButton* const& e) {
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ void Host::nameVanished(const Glib::RefPtr<Gio::DBus::Connection>& conn, const G
|
||||||
|
|
||||||
void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {
|
void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {
|
||||||
|
|
||||||
void Host::registerHost(GObject* src, GAsyncResult* res, gpointer data) {
|
void Host::registerHost(GObject* src, GAsyncResult* res, gpointer data) {
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ Watcher::~Watcher() {
|
||||||
|
|
||||||
void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib::ustring name) {
|
void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib::ustring name) {
|
||||||
GError* error = nullptr;
|
GError* error = nullptr;
|
||||||
waybar::util::scope_guard error_deleter([error]() {
|
waybar::util::ScopeGuard error_deleter([error]() {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue