diff --git a/src/command_scheduler.cc b/src/command_scheduler.cc index 4de7ae48..d2b11d3a 100644 --- a/src/command_scheduler.cc +++ b/src/command_scheduler.cc @@ -28,9 +28,10 @@ cmd_scheduler_simple_removed(core::Download* download) { control->core()->download_list()->pause(download); core::View* viewActive = *control->view_manager()->find("active"); + unsigned int numActive = viewActive->size_visible(); int64_t maxActive = rpc::call_command("scheduler.max_active", torrent::Object()).as_value(); - if ((int64_t)viewActive->size_visible() >= maxActive) + if ((int64_t)numActive >= maxActive) return torrent::Object(); // The 'started' view contains all the views we may choose amongst. @@ -41,6 +42,9 @@ cmd_scheduler_simple_removed(core::Download* download) { continue; control->core()->download_list()->resume(*itr); + + if ((int64_t)++numActive >= maxActive) + break; } return torrent::Object();