Skip to content

Commit

Permalink
scope_guard/modules: Rename scope_guard to ScopeGuard
Browse files Browse the repository at this point in the history
Using pascal case for the class name keeps it more consistent with the
majority of the other class names.
  • Loading branch information
taminob committed Oct 23, 2023
1 parent ffeeed8 commit c5b1703
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions include/util/scope_guard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace waybar::util {

template <typename Func>
class scope_guard {
class ScopeGuard {
public:
explicit scope_guard(Func&& exit_function) : f{std::forward<Func>(exit_function)} {}
scope_guard(const scope_guard&) = delete;
scope_guard(scope_guard&&) = default;
scope_guard& operator=(const scope_guard&) = delete;
scope_guard& operator=(scope_guard&&) = default;
~scope_guard() { f(); }
explicit ScopeGuard(Func&& exit_function) : f{std::forward<Func>(exit_function)} {}
ScopeGuard(const ScopeGuard&) = delete;
ScopeGuard(ScopeGuard&&) = default;
ScopeGuard& operator=(const ScopeGuard&) = delete;
ScopeGuard& operator=(ScopeGuard&&) = default;
~ScopeGuard() { f(); }

private:
Func f;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ using GDBusManager = std::unique_ptr<GDBusObjectManager, void (*)(GDBusObjectMan

auto generateManager() -> GDBusManager {
GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error) {
g_error_free(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void waybar::modules::Custom::continuousWorker() {
}
thread_ = [this, cmd] {
char* buff = nullptr;
waybar::util::scope_guard buff_deleter([buff]() {
waybar::util::ScopeGuard buff_deleter([buff]() {
if (buff) {
free(buff);
}
Expand Down
6 changes: 3 additions & 3 deletions src/modules/mpris/mpris.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
}

GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error) {
g_error_free(error);
}
Expand Down Expand Up @@ -482,7 +482,7 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
}

GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error) {
g_error_free(error);
}
Expand Down Expand Up @@ -580,7 +580,7 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {

bool Mpris::handleToggle(GdkEventButton* const& e) {
GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error) {
g_error_free(error);
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/sni/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error != nullptr) {
g_error_free(error);
}
Expand All @@ -81,7 +81,7 @@ void Host::proxyReady(GObject* src, GAsyncResult* res, gpointer data) {

void Host::registerHost(GObject* src, GAsyncResult* res, gpointer data) {
GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error != nullptr) {
g_error_free(error);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/sni/watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Watcher::~Watcher() {

void Watcher::busAcquired(const Glib::RefPtr<Gio::DBus::Connection>& conn, Glib::ustring name) {
GError* error = nullptr;
waybar::util::scope_guard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([error]() {
if (error) {
g_error_free(error);
}
Expand Down

0 comments on commit c5b1703

Please sign in to comment.