Merge lp:~niclasl/scratch/fix-1351611 into lp:~elementary-apps/scratch/scratch
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | xapantu | ||||
Approved revision: | 1345 | ||||
Merged at revision: | 1345 | ||||
Proposed branch: | lp:~niclasl/scratch/fix-1351611 | ||||
Merge into: | lp:~elementary-apps/scratch/scratch | ||||
Diff against target: |
30 lines (+11/-9) 1 file modified
src/Widgets/SourceView.vala (+11/-9) |
||||
To merge this branch: | bzr merge lp:~niclasl/scratch/fix-1351611 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
xapantu (community) | Approve | ||
Review via email: mp+229611@code.launchpad.net |
Commit message
Fix bug #1351611: The text in the sourceview buffer is now set synchronuously.
Description of the change
The text in the sourceview buffer is now set synchronuously.
The cause of the bug was that there was a window from that the content was loaded from file, to that the callback added to the Idle queue was executed where a call to save would clear the file.
A possible scenario where this would happen is:
1. Some files are opened when Scratch is opened
2. A "focus in" event loads the content of the active tab's file. The callback in set_text is queued.
3. The user switches tab, causing a "focus out" event on the old tab which calls save.
4. Save writes the current content of the empty buffer to file and sets the saved state to true
5. The callback gets executed, filling the buffer with the file content
6. The user closes Scratch. Since saved == true, the content in the buffer is not written to the (now empty) file.
Also, I could not find a reason why the buffer text assignment should be done in a Idle callback, so removing it should not introduce a threading issue.
It looks fine, even if it is hard to test. Removing the idle makes sense.