mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-17 15:42:30 +00:00
Fix display/UI crash and correctness bugs (@sirus20x6)
This commit is contained in:
@@ -60,6 +60,8 @@ retrieve_p_options_str(torrent::Peer* peer) {
|
||||
|
||||
torrent::Object
|
||||
retrieve_p_completed_percent(torrent::Peer* peer) {
|
||||
if (peer->bitfield()->size_bits() == 0)
|
||||
return int64_t(0);
|
||||
return (100 * peer->bitfield()->size_set()) / peer->bitfield()->size_bits();
|
||||
}
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ Frame::balance_row(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
(*itr)->balance(x, y, m_width, std::min((*itr)->m_height, height));
|
||||
|
||||
y += (*itr)->m_height;
|
||||
height -= (*itr)->m_height;
|
||||
height -= std::min(height, (*itr)->m_height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ Frame::balance_column(uint32_t x, uint32_t y, uint32_t width, uint32_t height) {
|
||||
(*itr)->balance(x, y, std::min((*itr)->m_width, width), m_height);
|
||||
|
||||
x += (*itr)->m_width;
|
||||
width -= (*itr)->m_width;
|
||||
width -= std::min(width, (*itr)->m_width);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ print_download_status(char* first, char* last, core::Download* d) {
|
||||
|
||||
if (d->is_hash_checking()) {
|
||||
first = print_buffer(first, last, "Checking hash [%2i%%]",
|
||||
(d->download()->chunks_hashed() * 100) / d->download()->file_list()->size_chunks());
|
||||
d->download()->file_list()->size_chunks() != 0 ? (d->download()->chunks_hashed() * 100) / d->download()->file_list()->size_chunks() : 0);
|
||||
|
||||
} else if (d->tracker_controller().has_active_trackers_not_scrape()) {
|
||||
auto tracker = d->tracker_controller().find_if([](const auto& t) {
|
||||
@@ -208,7 +208,7 @@ print_download_info_compact(char* first, char* last, core::Download* d) {
|
||||
if (d->is_done())
|
||||
first = print_buffer(first, last, " 100%% ");
|
||||
else if (d->is_open())
|
||||
first = print_buffer(first, last, " %2u%% ",(d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks());
|
||||
first = print_buffer(first, last, " %2u%% ", d->download()->file_list()->size_chunks() != 0 ? (d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks() : 0);
|
||||
else
|
||||
first = print_buffer(first, last, " ");
|
||||
|
||||
@@ -260,7 +260,7 @@ print_download_percentage_done(char* first, char* last, core::Download* d) {
|
||||
//return print_buffer(first, last, "[--%%]");
|
||||
return print_buffer(first, last, " ");
|
||||
else
|
||||
return print_buffer(first, last, "[%2u%%]", (d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks());
|
||||
return print_buffer(first, last, "[%2u%%]", d->download()->file_list()->size_chunks() != 0 ? (d->download()->file_list()->completed_chunks() * 100) / d->download()->file_list()->size_chunks() : 0);
|
||||
}
|
||||
|
||||
char*
|
||||
|
||||
@@ -19,7 +19,7 @@ WindowHttpQueue::WindowHttpQueue(core::HttpQueue* q) :
|
||||
set_active(false);
|
||||
|
||||
m_conn_insert = m_queue->signal_insert().insert(m_queue->signal_insert().end(), [this](auto h) { receive_insert(h); });
|
||||
m_conn_erase = m_queue->signal_erase().insert(m_queue->signal_insert().end(), [this](auto h) { receive_erase(h); });
|
||||
m_conn_erase = m_queue->signal_erase().insert(m_queue->signal_erase().end(), [this](auto h) { receive_erase(h); });
|
||||
|
||||
m_task_deactivate.slot() = [this] {
|
||||
if (!m_container.empty())
|
||||
|
||||
@@ -12,7 +12,7 @@ WindowInput::redraw() {
|
||||
m_canvas->erase();
|
||||
m_canvas->print(0, 0, "%s> %s", m_title.c_str(), m_input != NULL ? m_input->c_str() : "<NULL>");
|
||||
|
||||
if (m_focus)
|
||||
if (m_focus && m_input != NULL)
|
||||
m_canvas->set_attr(m_input->get_pos() + 2 + m_title.size(), 0, 1, A_REVERSE, COLOR_PAIR(0));
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,8 @@ ElementDownloadList::receive_home() {
|
||||
|
||||
void
|
||||
ElementDownloadList::receive_end() {
|
||||
if (m_view->size_visible() == 0)
|
||||
return;
|
||||
m_view->set_focus(m_view->end_visible() - 1);
|
||||
m_view->set_last_changed();
|
||||
}
|
||||
@@ -221,10 +223,10 @@ ElementDownloadList::receive_change_view(const std::string& name) {
|
||||
|
||||
std::string old_name = view() ? view()->name() : "";
|
||||
if (!old_name.empty())
|
||||
rpc::commands.call_catch("event.view.hide", rpc::make_target(), name, "View hide event action failed: ");
|
||||
rpc::commands.call_catch("event.view.hide", rpc::make_target(), old_name, "View hide event action failed: ");
|
||||
set_view(*itr);
|
||||
if (!old_name.empty())
|
||||
rpc::commands.call_catch("event.view.show", rpc::make_target(), old_name, "View show event action failed: ");
|
||||
if (!name.empty())
|
||||
rpc::commands.call_catch("event.view.show", rpc::make_target(), name, "View show event action failed: ");
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+1
-1
@@ -496,7 +496,7 @@ Root::set_keymap_style(const std::string& style) {
|
||||
} else if (style == "emacs") {
|
||||
m_keymap = emacs_keymap;
|
||||
} else {
|
||||
throw torrent::input_error("Root::set_keymap_style() -> ui.keymap.style is configured with unknown keymap style: " + m_keymap_style);
|
||||
throw torrent::input_error("Root::set_keymap_style() -> ui.keymap.style is configured with unknown keymap style: " + style);
|
||||
}
|
||||
|
||||
m_keymap_style = style;
|
||||
|
||||
Reference in New Issue
Block a user