From 83f7d2ce9193e4aea47d41b38b5a2fa1602e7eb2 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 9 Dec 2016 12:43:31 +0100 Subject: [PATCH] refactor: Cleanup --- include/x11/xresources.hpp | 3 ++- src/components/config.cpp | 4 ++-- src/components/controller.cpp | 2 +- src/components/logger.cpp | 7 +------ src/main.cpp | 10 ++++++---- src/x11/connection.cpp | 4 ++-- src/x11/xresources.cpp | 5 +++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/x11/xresources.hpp b/include/x11/xresources.hpp index 7649010c..5e132f9e 100644 --- a/include/x11/xresources.hpp +++ b/include/x11/xresources.hpp @@ -8,7 +8,8 @@ POLYBAR_NS class xresource_manager { public: - static const xresource_manager& make(); + using make_type = const xresource_manager&; + static make_type make(); explicit xresource_manager(); diff --git a/src/components/config.cpp b/src/components/config.cpp index b412bcb2..8ba12085 100644 --- a/src/components/config.cpp +++ b/src/components/config.cpp @@ -14,8 +14,8 @@ POLYBAR_NS * Create instance */ config::make_type config::make(string path, string bar) { - return static_cast( - *factory_util::singleton(logger::make(), xresource_manager::make(), move(path), move(bar))); + return static_cast(*factory_util::singleton>( + *factory_util::singleton(logger::make(), xresource_manager::make(), move(path), move(bar)))); } /** diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 242fca10..03ff3a0e 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -32,7 +32,7 @@ controller::make_type controller::make(string&& path_confwatch, bool enable_ipc, eventloop::make(), bar::make(), enable_ipc ? ipc::make() : ipc::make_type{}, - !path_confwatch.empty() ? inotify_util::make_watch(path_confwatch) : watch_t{}, + !path_confwatch.empty() ? inotify_util::make_watch(forward(path_confwatch)) : watch_t{}, writeback); // clang-format on } diff --git a/src/components/logger.cpp b/src/components/logger.cpp index f331b14e..1d2a2b0d 100644 --- a/src/components/logger.cpp +++ b/src/components/logger.cpp @@ -11,11 +11,6 @@ POLYBAR_NS * Create instance */ logger::make_type logger::make(loglevel level) { -#ifndef DEBUG - if (level == loglevel::TRACE) { - throw application_error("not a debug build: trace disabled..."); - } -#endif return static_cast(*factory_util::singleton(level)); } @@ -52,7 +47,7 @@ logger::logger(loglevel level) : m_level(level) { void logger::verbosity(loglevel&& level) { #ifndef DEBUG if (level == loglevel::TRACE) { - throw application_error("Not a debug build; trace disabled..."); + throw application_error("Trace logging is only enabled for debug builds..."); } #endif m_level = forward(level); diff --git a/src/main.cpp b/src/main.cpp index 0a37cb62..c5455344 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,8 +48,9 @@ int main(int argc, char** argv) { throw exit_failure{}; } - connection{xcbconn}.preload_atoms(); - connection{xcbconn}.query_extensions(); + connection conn{xcbconn}; + conn.preload_atoms(); + conn.query_extensions(); //================================================== // Block all signals by default @@ -160,8 +161,9 @@ int main(int argc, char** argv) { } try { - logger.info("Reload application..."); - process_util::exec(argv[0], argv); + logger.warn("Re-launching application..."); + logger.info("Re-launching application..."); + process_util::exec(move(argv[0]), move(argv)); } catch (const system_error& err) { logger.err("execlp() failed (%s)", strerror(errno)); } diff --git a/src/x11/connection.cpp b/src/x11/connection.cpp index 7d50bedf..c120c51f 100644 --- a/src/x11/connection.cpp +++ b/src/x11/connection.cpp @@ -12,8 +12,8 @@ POLYBAR_NS * Create instance */ connection::make_type connection::make() { - return static_cast( - *factory_util::singleton(xutils::get_connection(), xutils::get_connection_fd())); + return static_cast(*factory_util::singleton>( + xutils::get_connection(), xutils::get_connection_fd())); } /** diff --git a/src/x11/xresources.cpp b/src/x11/xresources.cpp index c79e8e17..7057ec06 100644 --- a/src/x11/xresources.cpp +++ b/src/x11/xresources.cpp @@ -11,8 +11,9 @@ POLYBAR_NS /** * Create instance */ -const xresource_manager& xresource_manager::make() { - return static_cast(*factory_util::singleton()); +xresource_manager::make_type xresource_manager::make() { + return static_cast( + *factory_util::singleton>()); } /**