Merge lp:~computergeoffrey/pantheon-photos/master into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by Geoffrey De Belie
Status: Merged
Approved by: Rico Tzschichholz
Approved revision: 3064
Merged at revision: 3072
Proposed branch: lp:~computergeoffrey/pantheon-photos/master
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 25 lines (+2/-2)
2 files modified
src/CollectionPage.vala (+1/-1)
src/library/RawsPage.vala (+1/-1)
To merge this branch: bzr merge lp:~computergeoffrey/pantheon-photos/master
Reviewer Review Type Date Requested Status
Rico Tzschichholz Approve
Adam Bieńkowski (community) code Approve
Geoffrey De Belie (community) Needs Resubmitting
Review via email: mp+311658@code.launchpad.net

Commit message

Fix segmentation fault in RawsPage.vala (triggered by clicking Raw Photos in the sidebar) and CollectionPage.vala

Description of the change

Fix segmentation fault in RawsPage.vala (triggered by clicking Raw Photos in the sidebar)

To post a comment you must log in.
Revision history for this message
Adam Bieńkowski (donadigo) wrote :

I would like to see it like this like that since we are no longer using "as":

public override bool include_in_view (DataSource source) {
    if (source is Photo) {
        return ((Photo)source).get_master_file_format () == PhotoFileFormat.RAW;
    }

    return false;
}

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

> I would like to see it like this like that since we are no longer using "as":

Why?

Using "as" is absolutely fine and better if there is actual access needed to the casted object.

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

ricotz: well, I saw that some of our projects started using (Type) casts, but okay then, it's not a requirement, I just wanted to point that out, it's still a good patch though.

Revision history for this message
Rico Tzschichholz (ricotz) wrote :

using an "unowned" local variable is mostly preferred to avoid superfluous implicit ref/unref calls

unowned Photo? photo = (source as Photo);

3063. By Geoffrey De Belie

Fix segmentation fault in RawsPage.vala (triggered by clicking Raw Photos in the sidebar)

Revision history for this message
Geoffrey De Belie (computergeoffrey) wrote :

I did as you suggested, using an unowned variable. I also reduced the lines changed to 1.

review: Needs Resubmitting
3064. By Geoffrey De Belie

Fix another segmentation fault, this time in CollectionPage.vala

Revision history for this message
Geoffrey De Belie (computergeoffrey) wrote :

I feel this second fix can be part of this merge request as well. Do you prefer a single commit or multiple commits?

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

The code looks good now, thanks.

review: Approve (code)
Revision history for this message
Rico Tzschichholz (ricotz) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/CollectionPage.vala'
2--- src/CollectionPage.vala 2016-11-21 07:11:02 +0000
3+++ src/CollectionPage.vala 2016-11-24 19:43:08 +0000
4@@ -281,7 +281,7 @@
5 if (get_view ().get_selected_count () != 1)
6 return;
7
8- Photo photo = (Photo) get_view ().get_selected_at (0).get_source ();
9+ unowned Photo? photo = get_view ().get_selected_at (0).get_source () as Photo;
10 try {
11 AppWindow.get_instance ().set_busy_cursor ();
12 photo.open_with_external_editor (app);
13
14=== modified file 'src/library/RawsPage.vala'
15--- src/library/RawsPage.vala 2016-09-19 21:18:06 +0000
16+++ src/library/RawsPage.vala 2016-11-24 19:43:08 +0000
17@@ -29,7 +29,7 @@
18 }
19
20 public override bool include_in_view (DataSource source) {
21- Photo photo = (Photo) source;
22+ unowned Photo? photo = source as Photo;
23 return photo != null && photo.get_master_file_format () == PhotoFileFormat.RAW;
24 }
25 }

Subscribers

People subscribed via source and target branches