Merge lp:~kurt.smolderen/scratch/fix-1232291 into lp:scratch/2.x

Proposed by Kurt Smolderen
Status: Merged
Merged at revision: 1227
Proposed branch: lp:~kurt.smolderen/scratch/fix-1232291
Merge into: lp:scratch/2.x
Diff against target: 69 lines (+25/-20)
1 file modified
src/Services/Document.vala (+25/-20)
To merge this branch: bzr merge lp:~kurt.smolderen/scratch/fix-1232291
Reviewer Review Type Date Requested Status
Mario Guerriero (community) Approve
Pim Vullers (community) Approve
Review via email: mp+188956@code.launchpad.net

Description of the change

Fixes issue lp:1232291 by connecting a 'dummy' handler to the SourceView.buffer.changed signal. This dummy implementation removes itself on the first call from the buffer and connects the 'real' handler instead.

The patch should also work for the trunk version, but as I'm still on Precise, I can't verify due to dependency on zeitgeist-2.0.

To post a comment you must log in.
Revision history for this message
Pim Vullers (pimvullers) wrote :

I've tried this patch against both 2.0.1 and trunk and it works as expected. Files are no longer marked as changed on open. I've already included this patch in the Gentoo ebuilds for scratch. Thanks Kurt for fixing this annoying bug.

review: Approve
Revision history for this message
Cody Garver (codygarver) wrote :

You should target lp:scratch with this instead of lp:scratch/2.x

Revision history for this message
Kurt Smolderen (kurt.smolderen) wrote :

Hey Cody,

Just filed a merge request for trunk. Omitted that at first because I did not have the opportunity to test the fix against trunk.

However, I would still like to see this bug fixed in the 2.x series as well as Luna-users are still using that major version due to zeitgeist dependencies.

Revision history for this message
Cody Garver (codygarver) wrote :

It would get backported

On Tue, Nov 12, 2013 at 2:44 PM, Kurt Smolderen <email address hidden>wrote:

> Hey Cody,
>
> Just filed a merge request for trunk. Omitted that at first because I did
> not have the opportunity to test the fix against trunk.
>
> However, I would still like to see this bug fixed in the 2.x series as
> well as Luna-users are still using that major version due to zeitgeist
> dependencies.
> --
>
> https://code.launchpad.net/~kurt.smolderen/scratch/fix-1232291/+merge/188956
> Your team elementary Apps team is requested to review the proposed merge
> of lp:~kurt.smolderen/scratch/fix-1232291 into lp:scratch/2.x.
>

--
Cody Garver

Revision history for this message
Mario Guerriero (mefrio-g) wrote :

it works good. Nice job!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Services/Document.vala'
2--- src/Services/Document.vala 2013-09-02 03:46:44 +0000
3+++ src/Services/Document.vala 2013-10-02 22:48:25 +0000
4@@ -53,6 +53,9 @@
5 // Zeitgeist integration
6 private ZeitgeistLogger zg_log = new ZeitgeistLogger();
7
8+ // It is used to not mark files as changed on load
9+ private ulong onchange_handler_id = 0;
10+
11 // Delegates
12 public delegate void VoidFunc ();
13
14@@ -115,7 +118,28 @@
15 this.working = true;
16 message ("Opening \"%s\"", get_basename ());
17
18-
19+ onchange_handler_id = this.source_view.buffer.changed.connect (() => {
20+ this.source_view.buffer.disconnect(onchange_handler_id);
21+ // Signals for SourceView
22+ uint timeout_saving = -1;
23+ this.source_view.buffer.changed.connect (() => {
24+ check_undoable_actions ();
25+ // Save if autosave is ON
26+ if (settings.autosave) {
27+ if (timeout_saving >= 0) {
28+ Source.remove (timeout_saving);
29+ timeout_saving = -1;
30+ }
31+ timeout_saving = Timeout.add (250, () => {
32+ save ();
33+ timeout_saving = -1;
34+ return false;
35+ });
36+ }
37+ else
38+ this.set_saved_status (false);
39+ });
40+ });
41
42 // Focus in event for SourceView
43 this.source_view.focus_in_event.connect (() => {
44@@ -445,25 +469,6 @@
45 this.source_view.set_text (text);
46 this.last_saved_content = text;
47 this.original_content = text;
48- // Signals for SourceView
49- uint timeout_saving = -1;
50- this.source_view.buffer.changed.connect (() => {
51- check_undoable_actions ();
52- // Save if autosave is ON
53- if (settings.autosave) {
54- if (timeout_saving >= 0) {
55- Source.remove (timeout_saving);
56- timeout_saving = -1;
57- }
58- timeout_saving = Timeout.add (250, () => {
59- save ();
60- timeout_saving = -1;
61- return false;
62- });
63- }
64- else if (!settings.autosave || file == null)
65- this.set_saved_status (false);
66- });
67 });
68 this.loaded = true;
69 }

Subscribers

People subscribed via source and target branches