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 770823 - Items are not removed from FAVORITES when unfavorited
Items are not removed from FAVORITES when unfavorited
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on: 770824
Blocks:
 
 
Reported: 2016-09-03 20:31 UTC by Umang Jain
Modified: 2016-09-11 22:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
item-manager: Clear mode specific items from all child base managers (2.03 KB, patch)
2016-09-04 00:34 UTC, Umang Jain
reviewed Details | Review
item-manager: Fix logic of marking favorites (999 bytes, patch)
2016-09-04 00:34 UTC, Umang Jain
committed Details | Review
item-manager: Reconnect "info-updated" signal handler while unhiding item (1.26 KB, patch)
2016-09-04 12:09 UTC, Umang Jain
needs-work Details | Review
item-manager: Remove items from FAVORITES when unfavorited (1008 bytes, patch)
2016-09-05 21:04 UTC, Debarshi Ray
committed Details | Review
item-manager: Reconnect to BaseItem::info-updated when unhiding item (1.02 KB, patch)
2016-09-06 16:55 UTC, Debarshi Ray
committed Details | Review

Description Umang Jain 2016-09-03 20:31:18 UTC
​
​​This can be seen in two parts:

(a) Favorite "star" is unresponsive
(b) Deleting an image under "Favorties" tab

(a) Steps to reproduce:

Case I:

1) Mark an image as favorite under selection mode.
2) Hop over to "Favorites" tab and unmark the image as favorite from selection mode.
3) You'll see the "star" disappears but the image is still present in the view
4) Hop over to "Photos" tab and try to mark the same image as favorite again. No "star" icon appears on the image.

At point #3, the image should be removed from the view. But it does not happen.

Case II:

1) Mark an image as favorite under selection mode.
2) Hop over to "Favorites" tab and terminate the application. Restart.
3) Now, in the overview, find the image you marked as favorite earlier.
4) Unmark it as favorite from selection mode.
5) Hop over to "Favorites" tab and come back to "Photos" tab.
5) Again try to mark the image as favorite from selection mode.
6) You should get output similar to : https://paste.gnome.org/p4nub0d0u


(b) Steps to reproduce:

1) Mark an image as favorite under selection mode.
2) Hop over to "Favorites" tab and try to delete the image using selection mode.
3) **ERROR:photos-item-manager.c:988:photos_item_manager_hide_item: 'item ==   
item1' should be TRUE encountered.

NOTE: Try resetting the tracker's database if you cannot reproduce using these steps.
Comment 1 Umang Jain 2016-09-03 23:01:22 UTC
There might be one more use case which needs to be fixed i.e. marking/unmarking favorite if image is a part of collection but I think that should be figured out exactly after we land patches for https://bugzilla.gnome.org/show_bug.cgi?id=770824
Comment 2 Umang Jain 2016-09-04 00:34:18 UTC
Created attachment 334735 [details] [review]
item-manager: Clear mode specific items from all child base managers
Comment 3 Umang Jain 2016-09-04 00:34:43 UTC
Created attachment 334736 [details] [review]
item-manager: Fix logic of marking favorites
Comment 4 Umang Jain 2016-09-04 12:09:10 UTC
Created attachment 334749 [details] [review]
item-manager: Reconnect "info-updated" signal handler while unhiding item

Case in which this patch will be useful:

1) Mark image as favorite
2) Hop over to "Favorites" tab
3) Delete that image using selection mode.
4) "Undo" delete (unhiding logic)
5) Try to unmark the image as favorite.

You will notice that the "star" on the image disappears but the image still remains in the view. This is because while removing the image, the "info-updated" signal handler got disconnected and thus, the handler is not called while unmarking the image as favorite (step 5).

Therefore, we should re-connect the handler while unhiding item.
Comment 5 Debarshi Ray 2016-09-05 20:53:05 UTC
Review of attachment 334735 [details] [review]:

Thanks for testing things, Umang. It is a big help.

::: src/photos-item-manager.c
@@ +867,1 @@
+              photos_base_manager_remove_object_by_id (self->item_mngr_chldrn[i], id);

Unfortunately, this is wrong. Clearing a child base manager should not affect the other children. Or at least I don't see why.
Comment 6 Debarshi Ray 2016-09-05 21:02:07 UTC
Review of attachment 334736 [details] [review]:

Good catch!

::: src/photos-item-manager.c
@@ +359,3 @@
         photos_base_manager_add_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_FAVORITES], G_OBJECT (item));
+      else
+        photos_base_manager_remove_object (self->item_mngr_chldrn[PHOTOS_WINDOW_MODE_FAVORITES], G_OBJECT (item));

Would be better if done a few lines below where we do all the removals.
Comment 7 Debarshi Ray 2016-09-05 21:04:56 UTC
Created attachment 334854 [details] [review]
item-manager: Remove items from FAVORITES when unfavorited
Comment 8 Debarshi Ray 2016-09-06 15:08:25 UTC
(In reply to Umang Jain from comment #0)
> (b) Steps to reproduce:
> 
> 1) Mark an image as favorite under selection mode.
> 2) Hop over to "Favorites" tab and try to delete the image using selection
> mode.
> 3) **ERROR:photos-item-manager.c:988:photos_item_manager_hide_item: 'item ==
> 
> item1' should be TRUE encountered.
> 
> NOTE: Try resetting the tracker's database if you cannot reproduce using
> these steps.

This seems to be fixed too.

I did see that if all items inside the view are deleted, we don't get the 'no-results' message. This is because the items are still present in the DB (which means that the queries are fooled), even though we fake their removal in the application. I would suggest filing a separate bug for that.
Comment 9 Debarshi Ray 2016-09-06 16:48:15 UTC
Review of attachment 334749 [details] [review]:

Nice catch, Umang. Thanks.

::: src/photos-item-manager.c
@@ +1017,3 @@
+        {
+          photos_base_manager_add_object (self->item_mngr_chldrn[i], G_OBJECT (item));
+          g_signal_connect_object (item, "info-updated", G_CALLBACK (photos_item_manager_info_updated), self, 0);

We don't need to connect multiple times, so better to move this outside.
Comment 10 Debarshi Ray 2016-09-06 16:55:07 UTC
Created attachment 334921 [details] [review]
item-manager: Reconnect to BaseItem::info-updated when unhiding item
Comment 11 Umang Jain 2016-09-06 19:07:04 UTC
Review of attachment 334921 [details] [review]:

Looks good to me.

All cases listed in above comments have been again tested with relevant patches applied. They are fixed now.
Can be closed after all patches have been pushed to master.
Comment 12 Debarshi Ray 2016-09-06 21:57:46 UTC
Thanks for testing, Umang.