* Fixed a bug where callinging download specific commands through the ui with no torrent selected would cause a crash.

* Added LT_SLIM_VERSION option that will leave out unneeded command redirects from the build.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1183 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2010-11-02 11:20:01 +00:00
parent b8d319a2fc
commit 0098b1f0b9
5 changed files with 16 additions and 22 deletions
+4 -4
View File
@@ -721,10 +721,10 @@ initialize_command_download() {
CMD2_DL_VALUE_V ("d.peers_min.set", std::tr1::bind(&torrent::ConnectionList::set_min_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.peers_max", std::tr1::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
CMD2_DL_VALUE_V ("d.peers_max.set", std::tr1::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.uploads_max", std::tr1::bind(&torrent::ConnectionList::max_size, CMD2_BIND_CL));
CMD2_DL_VALUE_V ("d.uploads_max.set", std::tr1::bind(&torrent::ConnectionList::set_max_size, CMD2_BIND_CL, std::tr1::placeholders::_2));
CMD2_DL ("d.peers_connected", std::tr1::bind(&torrent::ConnectionList::size, CMD2_BIND_CL));
CMD2_DL ("d.peers_not_connected", std::tr1::bind(&torrent::PeerList::available_list_size, CMD2_BIND_PL));
CMD2_DL ("d.uploads_max", std::tr1::bind(&torrent::Download::uploads_max, CMD2_BIND_DL));
CMD2_DL_VALUE_V ("d.uploads_max.set", std::tr1::bind(&torrent::Download::set_uploads_max, CMD2_BIND_DL, std::tr1::placeholders::_2));
CMD2_DL ("d.peers_connected", std::tr1::bind(&torrent::ConnectionList::size, CMD2_BIND_CL));
CMD2_DL ("d.peers_not_connected", std::tr1::bind(&torrent::PeerList::available_list_size, CMD2_BIND_PL));
CMD2_DL ("d.peers_complete", CMD2_ON_DL(peers_complete));
CMD2_DL ("d.peers_accounted", CMD2_ON_DL(peers_accounted));
+2 -1
View File
@@ -307,7 +307,8 @@ DownloadFactory::receive_success() {
torrent::HashString infohash = download->info()->hash();
try {
std::for_each(m_commands.begin(), m_commands.end(), rak::bind1st(std::ptr_fun(&rpc::parse_command_d_multiple_std), download));
std::for_each(m_commands.begin(), m_commands.end(),
rak::bind2nd(std::ptr_fun(&rpc::parse_command_multiple_std), rpc::make_target(download)));
if (m_manager->download_list()->find(infohash) == m_manager->download_list()->end())
throw torrent::input_error("The newly created download was removed.");
+2
View File
@@ -377,6 +377,7 @@ main(int argc, char** argv) {
CMD2_REDIRECT_GENERIC_NO_EXPORT("schedule_remove", "schedule_remove2");
}
#if LT_SLIM_VERSION == 1
if (rpc::call_command_value("method.use_deprecated")) {
// Deprecated in 0.7.0:
@@ -804,6 +805,7 @@ main(int argc, char** argv) {
CMD2_REDIRECT_GENERIC("execute_capture", "execute.capture");
CMD2_REDIRECT_GENERIC("execute_capture_nothrow", "execute.capture_nothrow");
}
#endif
int firstArg = parse_options(control, argc, argv);
+5 -16
View File
@@ -76,6 +76,11 @@ parse_command_single(target_type target, const std::string& cmd) {
return parse_command(target, cmd.c_str(), cmd.c_str() + cmd.size()).first;
}
inline torrent::Object
parse_command_multiple_std(const std::string& cmd, target_type target = rpc::make_target()) {
return parse_command_multiple(target, cmd.c_str(), cmd.c_str() + cmd.size());
}
inline void
parse_command_single_std(const std::string& cmd) {
parse_command(make_target(), cmd.c_str(), cmd.c_str() + cmd.size());
@@ -91,22 +96,6 @@ parse_command_multiple_d_nothrow(core::Download* download, const std::string& cm
}
}
inline void
parse_command_d_single_std(core::Download* download, const std::string& cmd) {
parse_command(make_target(download), cmd.c_str(), cmd.c_str() + cmd.size());
}
inline torrent::Object
parse_command_multiple_std(const std::string& cmd) {
return parse_command_multiple(make_target(), cmd.c_str(), cmd.c_str() + cmd.size());
}
inline torrent::Object
parse_command_d_multiple_std(core::Download* download, const std::string& cmd) {
return parse_command_multiple(make_target(download), cmd.c_str(), cmd.c_str() + cmd.size());
}
// inline torrent::Object call_command(const char* key, const torrent::Object& obj, target_type target = target_type((int)CommandMap::target_generic, NULL)) { return commands.call_command(key, obj); }
inline torrent::Object call_command (const char* key, const torrent::Object& obj, target_type target = make_target()) { return commands.call_command(key, obj, target); }
inline torrent::Object call_command_void (const char* key, target_type target = make_target()) { return commands.call_command(key, torrent::Object(), target); }
inline std::string call_command_string(const char* key, target_type target = make_target()) { return commands.call_command(key, torrent::Object(), target).as_string(); }
+3 -1
View File
@@ -318,7 +318,9 @@ DownloadList::receive_exit_input(Input type) {
break;
case INPUT_COMMAND:
rpc::parse_command_d_single_std(current_view()->focus() != current_view()->end_visible() ? *current_view()->focus() : NULL, input->str());
rpc::parse_command_single(current_view()->focus() != current_view()->end_visible() ?
rpc::make_target(*current_view()->focus()) : rpc::make_target(),
input->str());
break;
default: