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 626561 - SyncView does not work for a brief amount of time after EvWindow registers in DBUS.
SyncView does not work for a brief amount of time after EvWindow registers in...
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-08-10 19:22 UTC by José Aliste
Modified: 2011-07-14 08:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Preliminary patch. (4.82 KB, patch)
2010-08-20 20:15 UTC, José Aliste
none Details | Review
patch (2.41 KB, patch)
2010-09-01 21:20 UTC, José Aliste
committed Details | Review
patch to the daemon (3.40 KB, patch)
2010-09-01 21:53 UTC, José Aliste
none Details | Review

Description José Aliste 2010-08-10 19:22:05 UTC
Since the ev-window register in DBUS in the init, and the document is only set in the open_uri method, there is a brief amount of time (some miliseconds), where the SyncView method does not work (since the document pointer is null). 

This causes problems if I want to Spawn an Evince instance using FindDocument(uri, Spawn = True) and then right away get the window list and do a SyncView. So, in practice, the first time I do SyncView, it does not work. 

I really don't know how to fix this.
Comment 1 José Aliste 2010-08-20 20:15:39 UTC
Created attachment 168435 [details] [review]
Preliminary patch.

So I opted for the queue methods calls until the doc has loaded instead of adding a DocumentLoaded signal. Afterall, I think this is better for clients (not overcomplicating the DBUS api). 

Issues not (yet) addressed: 
- What happens if a doc is never loaded and you queue some method calls (this should never happen since there is no way of getting the unique name of a Evince instance with an empty window, but, I raise the concern nevertheless).
 
- (this probably belongs to a new bug) With the patch attached, Evince now performs the ForwardSearch as expected, but the EvView widget does not ensure that the result is visible.
Comment 2 José Aliste 2010-08-21 02:16:22 UTC
the second issue occurs since the syncview and therefore ensure_rectangle_is_visible is called before the View widget has allocated space (and hence the GtkAdjustments values are not correct)
Comment 3 José Aliste 2010-09-01 21:20:19 UTC
Created attachment 169292 [details] [review]
patch

as discussed in IRC, the previous patch has problems. We opted for emitting a DocumentLoaded DBus signal when the window finishes loading and subscribing to this signal in the Evince Daemon, so the evince daemon replys to FindDocument calls with spawn=true only after the window has loaded. Preventing the async issues of this bug. The patch attached add this signal. A patch to the daemon follows
Comment 4 José Aliste 2010-09-01 21:53:05 UTC
Created attachment 169299 [details] [review]
patch to the daemon
Comment 5 Carlos Garcia Campos 2010-09-08 12:24:17 UTC
Review of attachment 169292 [details] [review]:

Pushed, thanks!
Comment 6 Carlos Garcia Campos 2010-09-08 12:27:48 UTC
(In reply to comment #4)
> Created an attachment (id=169299) [details] [review]
> patch to the daemon

I've pushed a slightly different version of this patch. Instead of subscribing to the signal globally, we can do it per document, and since the signal will be emitted only once we can unsubscribe it as soon as we received it.
Comment 7 Peter B. Jørgensen 2011-07-11 23:07:56 UTC
I dont think this bug is fixed. I'm developing this gVim plugin
https://github.com/peder2tm/sved/blob/master/tex_evinceSync.vim

And I have discovered that when using the FindDocument method asynchronously with spawn=True, I will first receive the signal DocumentLoaded and then the FindDocument reply. 

As my plugin is now, it doesn't work correctly, because it is issuing the SyncView method too quickly, when the Evince window need to spawn. It works correctly if the document is already loaded.

If I add time.sleep(0.2) after line 149 in the .vim file, it also works when spawning, so it seems like there still is a race condition going on.

I'm using Evince 3.0.2 on Arch Linux.
Comment 8 Peter B. Jørgensen 2011-07-14 08:14:26 UTC
(In reply to comment #7)
> I dont think this bug is fixed. I'm developing this gVim plugin
> https://github.com/peder2tm/sved/blob/master/tex_evinceSync.vim
> 
> And I have discovered that when using the FindDocument method asynchronously
> with spawn=True, I will first receive the signal DocumentLoaded and then the
> FindDocument reply. 
> 
> As my plugin is now, it doesn't work correctly, because it is issuing the
> SyncView method too quickly, when the Evince window need to spawn. It works
> correctly if the document is already loaded.
> 
> If I add time.sleep(0.2) after line 149 in the .vim file, it also works when
> spawning, so it seems like there still is a race condition going on.
> 
> I'm using Evince 3.0.2 on Arch Linux.

OK, the bug I am referring to is really Bug #628375 so just forget comment #7