After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778138 - image-properties-page: port away from manual type decls
image-properties-page: port away from manual type decls
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
master
Other Linux
: Normal minor
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks: 771777
 
 
Reported: 2017-02-03 13:59 UTC by Ernestas Kulik
Modified: 2017-11-05 21:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
image-properties-page: port away from manual type decls (16.37 KB, patch)
2017-02-12 02:51 UTC, Kevin Lopez
none Details | Review
images-properties without g_clear_pointer (16.47 KB, patch)
2017-02-15 14:15 UTC, Kevin Lopez
none Details | Review
images-properties-with-g_clear-pointer (16.45 KB, patch)
2017-02-15 14:17 UTC, Kevin Lopez
none Details | Review
patch to image-properties (16.55 KB, patch)
2017-02-22 00:20 UTC, Kevin Lopez
none Details | Review
Patch to image-properties-page (16.60 KB, patch)
2017-02-23 10:59 UTC, Kevin Lopez
committed Details | Review

Description Ernestas Kulik 2017-02-03 13:59:45 UTC
See bug 771777.
Comment 1 Kevin Lopez 2017-02-12 02:51:37 UTC
Created attachment 345554 [details] [review]
image-properties-page: port away from manual type decls

I'm a little bit confused about how to decide if a type is derivable, or a final type, since this decision is made by the Nautilus Developers. 

It's easy to figure out if another type inherits from it. But in the other cases it isn't so clear for me.

So in this patch I decided declare it as a final type, it makes more sense, at least for me.

Anyway if I'm wrong, only tell me.
Comment 2 Ernestas Kulik 2017-02-12 18:20:44 UTC
> I'm a little bit confused about how to decide if a type is derivable, or a
> final type, since this decision is made by the Nautilus Developers. 

The code decides first and foremost. If the code does not tell anything conclusive, you choose and build a case for your choice. The Nautilus developers then decide whether or not to accept the change, based on your arguments.

This is rather simplified, but that is how I see it.

> It's easy to figure out if another type inherits from it. But in the other
> cases it isn't so clear for me.

That is a partial answer to your question. If you see it being derived from anywhere in the code, it definitely is derivable. If you see virtual methods, you should check if it is being derived from, then make the executive decision. I usually lean towards final types in such cases of ambiguity, as it removes confusion when trying to figure out what the class hierarchy looks like (there is also the benefit of not having to write extra code to access the private instance data).

A parallel can be drawn to C++ and/or other languages. You simply do not plaster every class with virtual methods “just in case”.

(This comment is not a review of your patch)
Comment 3 Ernestas Kulik 2017-02-15 09:27:21 UTC
Review of attachment 345554 [details] [review]:

Thanks for working on this! However, Nautilus crashes with your patch.

::: src/nautilus-image-properties-page.c
@@ +46,1 @@
 {

There’s something missing here. I suggest that you compile /and/ run Nautilus with your changes.

@@ +491,3 @@
     {
+        exif_loader_unref (page->exifldr);
+        page->exifldr = NULL;

Nice catch above with the g_clear_object (). See if you can use g_clear_pointer () here.

@@ +498,3 @@
     {
+        xmp_free (page->xmp);
+        page->xmp = NULL;

Maybe here as well.

::: src/nautilus-image-properties-page.h
@@ +30,1 @@
 GType nautilus_image_properties_page_get_type (void);

This is no longer needed.
Comment 4 Kevin Lopez 2017-02-15 14:13:01 UTC
(In reply to Ernestas Kulik from comment #3)
> ::: src/nautilus-image-properties-page.c
> @@ +46,1 @@
>  {
> 
> There’s something missing here. I suggest that you compile /and/ run
> Nautilus with your changes.

What a error, I forgot to add the parent object to the structure. Thanks for don't tell me what was my mistake. I took some time to find what fails, but I improved my skills with gdb. I tested now and runs ok.

> Nice catch above with the g_clear_object (). See if you can use
> g_clear_pointer () here.

With g_clear_pointer, I have to define a new function to destroy the pointer. Although I can use 

g_clear_pointer(&(page->xmp),g_free);

but  that adds a new invoke to the stack, so I think the current solution is ok. 

However, I uploaded two patches with the different solutions.
Comment 5 Kevin Lopez 2017-02-15 14:15:03 UTC
Created attachment 345826 [details] [review]
images-properties without g_clear_pointer

images-properties without g_clear_pointer
Comment 6 Kevin Lopez 2017-02-15 14:17:14 UTC
Created attachment 345827 [details] [review]
images-properties-with-g_clear-pointer

patch with g_clear_pointer ()
Comment 7 Ernestas Kulik 2017-02-18 07:24:39 UTC
Review of attachment 345826 [details] [review]:

Let’s focus on the main issue here and separate the changes. Reattach this patch without the change to g_clear_object () and we’ll go from there.
Comment 8 Ernestas Kulik 2017-02-18 07:37:05 UTC
(In reply to Kevin Lopez from comment #4)
> but  that adds a new invoke to the stack, so I think the current solution is
> ok.

Sure, but g_clear_object () does the exact same.

> However, I uploaded two patches with the different solutions.

For that reason, the changes should be separated as I said earlier. Half of your work is mergeable and merging it will result in smaller patches later.
Comment 9 Kevin Lopez 2017-02-22 00:20:43 UTC
Created attachment 346416 [details] [review]
patch to image-properties

(In reply to Ernestas Kulik from comment #7)
> Review of attachment 345826 [details] [review] [review]:
> 
> Let’s focus on the main issue here and separate the changes. Reattach this
> patch without the change to g_clear_object () and we’ll go from there.

Waiting your review to upload the other patch with g_clear_*.
Regards!
Comment 10 Ernestas Kulik 2017-02-22 15:34:57 UTC
Review of attachment 346416 [details] [review]:

Looks fine to me. Just remove a line and we’ll be able to move on to other things. :)

::: src/nautilus-image-properties-page.c
@@ +743,1 @@
 

Left a bit too much vertical whitespace here.
Comment 11 Kevin Lopez 2017-02-23 10:59:58 UTC
Created attachment 346558 [details] [review]
Patch to image-properties-page
Comment 12 Ernestas Kulik 2017-02-23 13:20:47 UTC
Review of attachment 346558 [details] [review]:

LGTM, thanks!
Comment 13 Carlos Soriano 2017-11-05 21:09:31 UTC
this is done