fix(xcb): Deallocate using deleter

This commit is contained in:
Michael Carlberg
2016-12-03 16:44:08 +01:00
parent 086e498388
commit ef9b37447b
9 changed files with 39 additions and 23 deletions

View File

@ -20,10 +20,6 @@ struct exit_success {};
struct exit_failure {};
int main(int argc, char** argv) {
uint8_t exit_code{EXIT_SUCCESS};
bool reload{false};
int xfd;
// clang-format off
const command_line::options opts{
command_line::option{"-h", "--help", "Show help options"},
@ -40,21 +36,20 @@ int main(int argc, char** argv) {
logger& logger{configure_logger<decltype(logger)>(loglevel::WARNING).create<decltype(logger)>()};
uint8_t exit_code{EXIT_SUCCESS};
bool reload{false};
try {
//==================================================
// Connect to X server
//==================================================
XInitThreads();
xcb_connection_t* connection{nullptr};
if ((connection = xutils::get_connection()) == nullptr) {
if (!xutils::get_connection()) {
logger.err("A connection to X could not be established... ");
throw exit_failure{};
}
xfd = xcb_get_file_descriptor(connection);
//==================================================
// Parse command line arguments
//==================================================
@ -139,10 +134,6 @@ int main(int argc, char** argv) {
exit_code = EXIT_FAILURE;
}
if (xfd != 0) {
close(xfd);
}
if (!reload) {
logger.info("Reached end of application...");
return exit_code;