Skip to content

Commit

Permalink
Merge pull request #1085 from vktr/fix/tracker-tier-removing
Browse files Browse the repository at this point in the history
Fix removing trackers and tiers
  • Loading branch information
vktr committed Dec 27, 2020
2 parents 4e8b60d + 80ede85 commit a8733db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions src/picotorrent/ui/models/trackerlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
if (m_dht == nullptr)
{
m_dht = std::make_shared<ListItem>();
m_dht->key = L"DHT";
m_dht->key = "DHT";
m_dht->tier = -1;

m_items.insert(
Expand All @@ -66,7 +66,7 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
if (m_lsd == nullptr)
{
m_lsd = std::make_shared<ListItem>();
m_lsd->key = L"LSD";
m_lsd->key = "LSD";
m_lsd->tier = -1;

m_items.insert(
Expand All @@ -79,7 +79,7 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
if (m_pex == nullptr)
{
m_pex = std::make_shared<ListItem>();
m_pex->key = L"PeX";
m_pex->key = "PeX";
m_pex->tier = -1;

m_items.insert(
Expand Down Expand Up @@ -144,7 +144,7 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
trackers.end(),
[tierIterator, trackerIterator](lt::announce_entry const& ae)
{
return Utils::toStdWString(ae.url) == (*trackerIterator)->key
return ae.url == (*trackerIterator)->key
&& ae.tier == (*tierIterator)->tier;
});

Expand Down Expand Up @@ -191,7 +191,7 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
if (tierIter == m_items.end())
{
auto newTier = std::make_shared<ListItem>();
newTier->key = fmt::format(i18n("tier_n"), iter->tier);
newTier->key = Utils::toStdString(fmt::format(i18n("tier_n"), iter->tier));
newTier->tier = iter->tier;

m_items.push_back(newTier);
Expand All @@ -217,13 +217,13 @@ void TrackerListModel::Update(BitTorrent::TorrentHandle* torrent)
[iter](auto const& itm)
{
return itm->tier == iter->tier
&& itm->key == Utils::toStdWString(iter->url);
&& itm->key == iter->url;
});

if (trackerIter == (*tierIter)->children.end())
{
auto newTracker = std::make_shared<ListItem>();
newTracker->key = Utils::toStdWString(iter->url);
newTracker->key = iter->url;
newTracker->parent = (*tierIter);
newTracker->tier = iter->tier;

Expand Down Expand Up @@ -301,7 +301,7 @@ void TrackerListModel::GetValue(wxVariant& variant, const wxDataViewItem& item,
{
case Column::Url:
{
variant = li->key;
variant = Utils::toStdWString(li->key);
break;
}
case Column::Status:
Expand Down
2 changes: 1 addition & 1 deletion src/picotorrent/ui/models/trackerlistmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace Models

struct ListItem
{
std::wstring key;
std::string key;
int tier;
ListItemStatus status;
int numDownloaded;
Expand Down
5 changes: 4 additions & 1 deletion src/picotorrent/ui/torrentdetailstrackerspanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ void TorrentDetailsTrackersPanel::ShowTrackerContextMenu(wxDataViewEvent& evt)
return ae.tier == item->tier && ae.url == item->key;
});

if (selectedTracker == originalTrackers.end())
if ((evt.GetId() == ptID_CONTEXT_MENU_COPY_URL
|| evt.GetId() == ptID_CONTEXT_MENU_FORCE_REANNOUNCE
|| evt.GetId() == ptID_CONTEXT_MENU_SCRAPE)
&& selectedTracker == originalTrackers.end())
{
BOOST_LOG_TRIVIAL(warning) << "Could not find selected tracker in torrent trackers: " << item->key;
return;
Expand Down

0 comments on commit a8733db

Please sign in to comment.