diff --git a/src/rpc/command_scheduler.cc b/src/rpc/command_scheduler.cc index a3956f7a..16410046 100644 --- a/src/rpc/command_scheduler.cc +++ b/src/rpc/command_scheduler.cc @@ -61,14 +61,20 @@ CommandScheduler::call_item(value_type item) { // Remove the item before calling the command if it should be // removed. + std::string key = item->key(); + try { rpc::call_object(item->command()); } catch (torrent::input_error& e) { if (m_slotErrorMessage) - m_slotErrorMessage("Scheduled command failed: " + item->key() + ": " + e.what()); + m_slotErrorMessage("Scheduled command failed: " + key + ": " + e.what()); } + // The command is allowed to erase or replace this item, which deletes it. + if (std::find(begin(), end(), item) == end()) + return; + // Still schedule if we caught a torrrent::input_error? auto next = item->next_time_scheduled();