mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-02 14:13:48 +00:00
Make updating diff asynchronously and be called on Idle
Before this commit, huge changes will affect the performance of the application A lot due to fetching the changes and showing them on the screen. This commit helps in reducing the lag a bit, by moving the updating and buffering The changes to Idle.
This commit is contained in:
parent
4aaf3fd368
commit
e8186875a8
|
@ -57,6 +57,8 @@ public class Gitg.DiffView : Gtk.Grid
|
||||||
private uint d_reveal_options_timeout;
|
private uint d_reveal_options_timeout;
|
||||||
private uint d_unreveal_options_timeout;
|
private uint d_unreveal_options_timeout;
|
||||||
|
|
||||||
|
private uint d_update_diff_id;
|
||||||
|
|
||||||
private static Gee.HashSet<string> s_image_mime_types;
|
private static Gee.HashSet<string> s_image_mime_types;
|
||||||
|
|
||||||
public Ggit.DiffOptions options
|
public Ggit.DiffOptions options
|
||||||
|
@ -231,6 +233,12 @@ public class Gitg.DiffView : Gtk.Grid
|
||||||
d_cancellable.cancel();
|
d_cancellable.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(d_update_diff_id != 0)
|
||||||
|
{
|
||||||
|
Source.remove(d_update_diff_id);
|
||||||
|
d_update_diff_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
base.dispose();
|
base.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +598,22 @@ public class Gitg.DiffView : Gtk.Grid
|
||||||
|
|
||||||
if (d_diff != null)
|
if (d_diff != null)
|
||||||
{
|
{
|
||||||
update_diff(d_diff, preserve_expanded, d_cancellable);
|
if(d_update_diff_id != 0)
|
||||||
|
{
|
||||||
|
Source.remove(d_update_diff_id);
|
||||||
|
d_update_diff_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
d_update_diff_id = Idle.add(() => {
|
||||||
|
update_diff.begin(d_diff,
|
||||||
|
preserve_expanded,
|
||||||
|
d_cancellable,
|
||||||
|
(obj, res) => {
|
||||||
|
d_update_diff_id = 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +715,7 @@ public class Gitg.DiffView : Gtk.Grid
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update_diff(Ggit.Diff diff, bool preserve_expanded, Cancellable? cancellable)
|
private async void update_diff(Ggit.Diff diff, bool preserve_expanded, Cancellable? cancellable)
|
||||||
{
|
{
|
||||||
var nqueries = 0;
|
var nqueries = 0;
|
||||||
var finished = false;
|
var finished = false;
|
||||||
|
|
Loading…
Reference in a new issue