summaryrefslogtreecommitdiff
path: root/src/trg-main-window.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-11 19:52:57 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2012-01-11 19:52:57 +0000
commit41a8f63ce28e228611d72156abb39d496691d8be (patch)
treef895d3226e39c5659a2af1531216ab028d6c1b06 /src/trg-main-window.c
parent1a7fff1b49628c2d3a0c8b9140196dd5ca4c2c8c (diff)
fix memory leaks and parse a files tree in a thread if there's over 600 files, to avoid UI freezes on massive torrents.
Diffstat (limited to 'src/trg-main-window.c')
-rw-r--r--src/trg-main-window.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/trg-main-window.c b/src/trg-main-window.c
index aa074f2..e4bea05 100644
--- a/src/trg-main-window.c
+++ b/src/trg-main-window.c
@@ -887,6 +887,13 @@ gboolean on_session_set(gpointer data) {
return FALSE;
}
+static gboolean hasEnabledChanged(JsonObject *a, JsonObject *b,
+ const gchar *key)
+{
+ return json_object_get_boolean_member(a, key) !=
+ json_object_get_boolean_member(b, key);
+}
+
static gboolean on_session_get(gpointer data) {
trg_response *response = (trg_response *) data;
TrgMainWindow *win = TRG_MAIN_WINDOW(response->cb_data);
@@ -935,14 +942,10 @@ static gboolean on_session_get(gpointer data) {
&& g_strcmp0(session_get_download_dir(lastSession),
session_get_download_dir(newSession));
gboolean refreshSpeed = lastSession
- && ((session_get_alt_speed_enabled(lastSession)
- != session_get_alt_speed_enabled(newSession))
- || (session_get_speed_limit_down_enabled(lastSession)
- != session_get_speed_limit_down_enabled(
- newSession))
- || (session_get_speed_limit_up_enabled(lastSession)
- != session_get_speed_limit_up_enabled(
- newSession)));
+ &&
+ (hasEnabledChanged(lastSession, newSession, SGET_ALT_SPEED_ENABLED)
+ || hasEnabledChanged(lastSession, newSession, SGET_SPEED_LIMIT_DOWN_ENABLED)
+ || hasEnabledChanged(lastSession, newSession, SGET_SPEED_LIMIT_UP_ENABLED));
trg_client_set_session(client, newSession);