Revert "refactor: move tr_torrent callbacks to tr_session (#3003)" (#3104)

This reverts commit 27fbfd8da6.

Fixes #3088.
This commit is contained in:
Charles Kerr
2022-05-16 13:48:43 -05:00
committed by GitHub
parent e23a4b3589
commit a28b07b390
9 changed files with 145 additions and 130 deletions

View File

@@ -813,8 +813,8 @@ Session::Session(tr_session* session)
Session::~Session() = default;
Session::Impl::Impl(Session& core, tr_session* session)
: core_{ core }
, session_{ session }
: core_(core)
, session_(session)
{
raw_model_ = Gtk::ListStore::create(torrent_cols);
sorted_model_ = Gtk::TreeModelSort::create(raw_model_);
@@ -828,16 +828,6 @@ Session::Impl::Impl(Session& core, tr_session* session)
on_pref_changed(TR_KEY_peer_limit_global);
on_pref_changed(TR_KEY_inhibit_desktop_hibernation);
signal_prefs_changed.connect([this](auto key) { on_pref_changed(key); });
tr_sessionSetMetadataCallback(
session_,
[](auto* tor2, gpointer impl) { static_cast<Impl*>(impl)->on_torrent_metadata_changed(tor2); },
this);
tr_sessionSetCompletenessCallback(
session_,
[](auto* tor2, auto completeness, bool was_running, gpointer impl)
{ static_cast<Impl*>(impl)->on_torrent_completeness_changed(tor2, completeness, was_running); },
this);
}
tr_session* Session::close()
@@ -996,6 +986,16 @@ void Session::Impl::add_torrent(tr_torrent* tor, bool do_notify)
{
gtr_notify_torrent_added(get_core_ptr(), tr_torrentId(tor));
}
tr_torrentSetMetadataCallback(
tor,
[](auto* tor2, gpointer impl) { static_cast<Impl*>(impl)->on_torrent_metadata_changed(tor2); },
this);
tr_torrentSetCompletenessCallback(
tor,
[](auto* tor2, auto completeness, bool was_running, gpointer impl)
{ static_cast<Impl*>(impl)->on_torrent_completeness_changed(tor2, completeness, was_running); },
this);
}
}