diff --git a/examples/client_test.cpp b/examples/client_test.cpp index a5f37d41f..51433a10b 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -895,7 +895,7 @@ bool handle_alert(torrent_view& view, session_view& ses_view // the alert handler for save_resume_data_alert // will save it to disk torrent_handle h = p->handle; - h.save_resume_data(); + h.save_resume_data(torrent_handle::save_info_dict); ++num_outstanding_resume_data; } else if (save_resume_data_alert* p = alert_cast(a)) @@ -919,7 +919,7 @@ bool handle_alert(torrent_view& view, session_view& ses_view // the alert handler for save_resume_data_alert // will save it to disk torrent_handle h = p->handle; - h.save_resume_data(); + h.save_resume_data(torrent_handle::save_info_dict); ++num_outstanding_resume_data; } else if (state_update_alert* p = alert_cast(a)) @@ -936,7 +936,7 @@ bool handle_alert(torrent_view& view, session_view& ses_view } void pop_alerts(torrent_view& view, session_view& ses_view - , libtorrent::session& ses, std::deque events) + , libtorrent::session& ses, std::deque& events) { std::vector alerts; ses.pop_alerts(&alerts); @@ -1860,10 +1860,11 @@ MAGNETURL is a magnet link continue; } - int progress = ti->files().file_size(i) > 0 + int const progress = ti->files().file_size(i) > 0 ? int(file_progress[idx] * 1000 / ti->files().file_size(i)) : 1000; + assert(file_progress[idx] <= ti->files().file_size(i)); - bool complete = file_progress[idx] == ti->files().file_size(i); + bool const complete = file_progress[idx] == ti->files().file_size(i); std::string title = ti->files().file_name(i).to_string(); if (!complete) diff --git a/examples/torrent_view.cpp b/examples/torrent_view.cpp index 337c1e8d3..7295a4063 100644 --- a/examples/torrent_view.cpp +++ b/examples/torrent_view.cpp @@ -362,7 +362,6 @@ bool torrent_view::show_torrent(lt::torrent_status const& st) // visible or filtered void torrent_view::update_filtered_torrents() { - m_scroll_position = 0; m_filtered_handles.clear(); for (auto const& h : m_all_handles) { @@ -373,5 +372,9 @@ void torrent_view::update_filtered_torrents() if (m_active_torrent < 0) m_active_torrent = 0; TORRENT_ASSERT(m_active_torrent >= 0); std::sort(m_filtered_handles.begin(), m_filtered_handles.end(), &compare_torrent); + if (m_scroll_position + m_height - header_size > int(m_filtered_handles.size())) + { + m_scroll_position = std::max(0, int(m_filtered_handles.size()) - m_height + header_size); + } } diff --git a/include/libtorrent/debug.hpp b/include/libtorrent/debug.hpp index 1cab2ecf3..d01708a6c 100644 --- a/include/libtorrent/debug.hpp +++ b/include/libtorrent/debug.hpp @@ -128,7 +128,7 @@ namespace libtorrent mach_msg_type_number_t t_info_count = task_events_info_count; task_info(mach_task_self(), TASK_EVENTS_INFO, reinterpret_cast(&teinfo), &t_info_count); - w.context_switches = teinfo.csw; + w.context_switches = static_cast(teinfo.csw); #else w.context_switches = 0; #endif diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 1c21b055b..655fe112c 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -5741,10 +5741,9 @@ namespace aux { std::uint64_t prev_csw = 0; if (!_wakeups.empty()) prev_csw = _wakeups[0].context_switches; std::fprintf(f, "abs. time\trel. time\tctx switch\tidle-wakeup\toperation\n"); - for (int i = 0; i < _wakeups.size(); ++i) + for (wakeup_t const& w : _wakeups) { - wakeup_t const& w = _wakeups[i]; - bool idle_wakeup = w.context_switches > prev_csw; + bool const idle_wakeup = w.context_switches > prev_csw; std::fprintf(f, "%" PRId64 "\t%" PRId64 "\t%" PRId64 "\t%c\t%s\n" , total_microseconds(w.timestamp - m) , total_microseconds(w.timestamp - prev) diff --git a/src/torrent.cpp b/src/torrent.cpp index 6b266fbbd..c02fe52aa 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5994,7 +5994,7 @@ namespace libtorrent bitmask.resize(num_blocks_per_piece, false); auto const info = m_picker->blocks_for_piece(dp); - for (int i = 0; i < num_blocks_per_piece; ++i) + for (int i = 0; i < int(info.size()); ++i) { if (info[i].state == piece_picker::block_info::state_finished) bitmask.set_bit(i);