summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Franz König <Arlon1@users.noreply.github.com> 2017-08-29 01:03:24 +0200
committerGravatar Franz König <Arlon1@users.noreply.github.com> 2017-08-29 01:03:24 +0200
commit7455313cf730cba1470b9b4ab5fe3554ff19c628 (patch)
tree9dd95b9f93efb7e76773c74a3a0e727f0948acb6
parent930605cac684e351e58c797fe4d376d50a16f5de (diff)
downloadnewsboat-7455313cf730cba1470b9b4ab5fe3554ff19c628.tar.gz
newsboat-7455313cf730cba1470b9b4ab5fe3554ff19c628.tar.zst
newsboat-7455313cf730cba1470b9b4ab5fe3554ff19c628.zip
improved code quality according to Minoru's advice
-rw-r--r--include/pb_view.h2
-rw-r--r--src/controller.cpp11
-rw-r--r--src/itemview_formaction.cpp3
-rw-r--r--src/pb_controller.cpp7
-rw-r--r--src/urlview_formaction.cpp2
-rw-r--r--src/utils.cpp7
6 files changed, 14 insertions, 18 deletions
diff --git a/include/pb_view.h b/include/pb_view.h
index 490fd856..35f3e7a7 100644
--- a/include/pb_view.h
+++ b/include/pb_view.h
@@ -40,6 +40,8 @@ class pb_view {
std::string prepare_keymaphint(keymap_hint_entry * hints);
pb_controller * ctrl;
newsbeuter::stfl::form dllist_form;
+ friend class pb_controller; // to use newsbeuter::stfl::form::set()
+
newsbeuter::stfl::form help_form;
newsbeuter::keymap * keys;
};
diff --git a/src/controller.cpp b/src/controller.cpp
index 53b6dbe8..e8e065e7 100644
--- a/src/controller.cpp
+++ b/src/controller.cpp
@@ -1317,11 +1317,12 @@ void controller::edit_urls_file() {
v->push_empty_formaction();
stfl::reset();
- /* We should not check this particular exit code.
- * Editors usually fail when closing+saving (and stay open).
- * (tested with vim, nano, gedit, geany)
- * (texmaker 5.0.1 and notepadqq 1.0.1 close without neither showing an
- * error nor saving but despite return 0)
+ /* Most editors check for unsaved changes when attempting to exit and
+ * prompt to either save or discard them. If save was choosen without
+ * having write permissions a properly codd will fail and stay open
+ * (like vim, nano, gedit, geany). However other editors (texmaker
+ * 5.0.1 and notepadqq 1.0.1) close but despite return 0.
+ * So we should not check this particular exit code.
*/
int unused __attribute__((unused));
unused = utils::run_interactively(cmdline, "controller::edit_urls_file");
diff --git a/src/itemview_formaction.cpp b/src/itemview_formaction.cpp
index 96062999..53f6d5ea 100644
--- a/src/itemview_formaction.cpp
+++ b/src/itemview_formaction.cpp
@@ -214,7 +214,6 @@ void itemview_formaction::process_operation(operation op, bool automatic, std::v
if (!v->open_in_browser(item->link())) {
v->show_error(_("Browser failed to open the link!"));
}
- v->set_status("");
break;
case OP_BOOKMARK:
if (automatic) {
@@ -375,7 +374,6 @@ void itemview_formaction::process_operation(operation op, bool automatic, std::v
if (!v->open_in_browser(links[idx].first)) {
v->show_error(_("Browser failed to open the link!"));
}
- v->set_status("");
}
}
break;
@@ -525,7 +523,6 @@ void itemview_formaction::finished_qna(operation op) {
if (!v->open_in_browser(links[idx-1].first)) {
v->show_error(_("Browser failed to open the link!"));
}
- v->set_status("");
}
}
break;
diff --git a/src/pb_controller.cpp b/src/pb_controller.cpp
index b95c18e9..c65e95de 100644
--- a/src/pb_controller.cpp
+++ b/src/pb_controller.cpp
@@ -371,9 +371,10 @@ void pb_controller::play_file(const std::string& file) {
cmdline.append(utils::replace_all(file,"\"", "\\\""));
cmdline.append("\"");
stfl::reset();
- // Is the following exit code important?
- int unused __attribute__((unused));
- unused = utils::run_interactively(cmdline, "pb_controller::play_file");
+ int player_exit_code = utils::run_interactively(cmdline, "pb_controller::play_file");
+ if (player_exit_code != 0) {
+ v->dllist_form.set("msg", _("The player failed!"));
+ }
}
diff --git a/src/urlview_formaction.cpp b/src/urlview_formaction.cpp
index 7a2a9fda..60942d07 100644
--- a/src/urlview_formaction.cpp
+++ b/src/urlview_formaction.cpp
@@ -33,7 +33,6 @@ void urlview_formaction::process_operation(operation op, bool /* automatic */, s
if (!v->open_in_browser(links[idx].first)) {
v->show_error(_("Browser failed to open the link!"));
}
- v->set_status("");
} else {
v->show_error(_("No link selected!"));
}
@@ -68,7 +67,6 @@ void urlview_formaction::process_operation(operation op, bool /* automatic */, s
if (!v->open_in_browser(links[idx].first)) {
v->show_error(_("Browser failed to open the link!"));
}
- v->set_status("");
}
}
break;
diff --git a/src/utils.cpp b/src/utils.cpp
index 4f8bfed0..47aeefbd 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -1101,12 +1101,9 @@ int utils::run_interactively(
LOG(level::DEBUG, "%s: couldn't create a child process", caller);
} else if (status == 127) {
LOG(level::DEBUG, "%s: couldn't run shell", caller);
+ } else if (status != 0) {
+ LOG(level::DEBUG, "%s: cmd = %s, returned %d", caller, command, status);
}
- if (status != 0) {
- LOG(level::DEBUG, "utils::run_interactively: "
- "%s: cmd = %s, returned %d", caller, command, status);
- }
-
return status;
}