fix resume data issue in client_test and some warnings (#1897)

fix resume data issue in client_test and some warnings
This commit is contained in:
Arvid Norberg 2017-04-09 09:37:06 -04:00 committed by GitHub
parent c35718d322
commit 09274842f7
5 changed files with 14 additions and 11 deletions

View File

@ -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<save_resume_data_alert>(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<state_update_alert>(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<std::string> events)
, libtorrent::session& ses, std::deque<std::string>& events)
{
std::vector<lt::alert*> 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)

View File

@ -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);
}
}

View File

@ -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<task_info_t>(&teinfo), &t_info_count);
w.context_switches = teinfo.csw;
w.context_switches = static_cast<std::uint64_t>(teinfo.csw);
#else
w.context_switches = 0;
#endif

View File

@ -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)

View File

@ -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);