Merge lp://qastaging/~3v1n0/bamf/libreoffice-fixes into lp://qastaging/bamf/0.4

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Mikkel Kamstrup Erlandsen
Approved revision: 443
Merged at revision: 424
Proposed branch: lp://qastaging/~3v1n0/bamf/libreoffice-fixes
Merge into: lp://qastaging/bamf/0.4
Diff against target: 805 lines (+327/-147)
8 files modified
configure.in (+1/-1)
src/bamf-application.c (+15/-2)
src/bamf-legacy-screen.c (+31/-0)
src/bamf-legacy-screen.h (+2/-0)
src/bamf-legacy-window.c (+35/-7)
src/bamf-legacy-window.h (+2/-0)
src/bamf-matcher.c (+234/-136)
src/bamf-view.c (+7/-1)
To merge this branch: bzr merge lp://qastaging/~3v1n0/bamf/libreoffice-fixes
Reviewer Review Type Date Requested Status
Mikkel Kamstrup Erlandsen (community) Approve
Review via email: mp+85395@code.qastaging.launchpad.net

Commit message

Fixed LibreOffice and OpenOffice compatibility, remapping windows to their real type

Description of the change

When a window can be mapped as a LibreOffice / OpenOffice application we look for the right hint for the given window, we set that hint by default (if valid) and we connect to the window's name-changed event.
So, every time the window name changes, we check again for the window type and if it has changed (i.e. we moved from writer to start-center), then we simulate a window open/close event that cause the window to be re-mapped to
the proper application.
This works very well and allows to change the application type on run-time.

Also, every recognized libreoffice window that doesn't match any main application, is now considered as a "Standard" libreoffice application window, using the libreoffice-startcenter icon.
This allows to correctly match not only the start center, but also dialog windows such as the restore window that shows up after a crash.
I also tried to introduce matching based on window class names (using libreoffice-writer, libreoffice-calc ... values), but since these parameters get updated only after the window name change, this check could be confusing (also if theoretically more secure).

The splash screen and the toolbars are now ignored, and so don't respect the rules above.

I've also included some optimizations, fixes (memleaks) and code cleanup.

To post a comment you must log in.
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Firstly - I LOVE you for getting rid of all the 'key = g_new (gint, 1);' that just gross in so many ways :-) Now for some comments:

8 - icon = g_icon_to_string (gicon);
9 +
10 + if (gicon)
11 + icon = g_icon_to_string (gicon);

The function you're updating here, bamf_application_setup_icon_and_name(), seems to leak self->priv->icon right at the end if it's set before we assign it. Can you plug that while you're here?

30 void
31 +bamf_legacy_screen_inject_window (BamfLegacyScreen *self, guint xid)

It's not totally clear to me what this function is intended to do. Can you add a short docstring? (I assume most ppl wont bother to dig out of the revision history like me ;-))

94 +void
95 +bamf_legacy_window_reopen (BamfLegacyWindow *self)

Same as the last new function :-)

101 + g_object_weak_ref (G_OBJECT (self), (GWeakNotify) handle_destroy_notify,
102 + GUINT_TO_POINTER (xid));

It's not very clear what the magic behind this weak ref is, could you add an explanatory comment?

373 + g_list_free_full (possible_apps, g_free);

The introduction of g_list_free_full() is nice, but requires glib >=2.28. Please add that check to configure.in.

423 + if (!g_hash_table_lookup (registered_pids, key))
424 + {
425 + g_hash_table_insert (registered_pids, key, g_strdup (window_hint));
426 + }

Only updating if we don't already know the pid seems like it could cause things to go askew? If that's not the case I think this logic requires a comment in the code.

628 static void
629 +bamf_matcher_dispose (GObject *object)

This function does not look like it's safe to run N times on the same object. That is the contract of dispose(). Fx. looking at this block makes me suspicious:

642 + g_array_free (priv->bad_prefixes, TRUE);
643 + g_array_free (priv->known_pids, TRUE);
644 + g_hash_table_destroy (priv->desktop_id_table);
645 + g_hash_table_destroy (priv->desktop_file_table);
646 + g_hash_table_destroy (priv->desktop_class_table);
647 + g_hash_table_destroy (priv->registered_pids);

You must add NULL-ification and NULL-checking on all members. If you don't want that override finalize() instead which is guaranteed to run only once.

695 + GObject *old_object = dbus_g_connection_lookup_g_object (bus, path);
696 + if (G_IS_OBJECT (old_object))
697 + {
698 + dbus_g_connection_unregister_g_object (bus, old_object);
699 + }

The commit message for this chunk mentions that you log a g_critical()when you replace an object. I don't see that critical being logged - is that intentional?

review: Needs Fixing
436. By Marco Trevisan (Treviño)

BamfApplication: don't leak the icon string

437. By Marco Trevisan (Treviño)

Configure.in: set glib-2.0 >= 2.28 to support g_list_free_full

438. By Marco Trevisan (Treviño)

BamfMatcher: use finalize function, instead of dispose.

439. By Marco Trevisan (Treviño)

BamfView: emit a g_critical message when unregistering a DBus object

440. By Marco Trevisan (Treviño)

BamfLegacyScreen: added docs to bamf_legacy_screen_inject_window

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

> Firstly - I LOVE you for getting rid of all the 'key = g_new (gint, 1);' that
> just gross in so many ways :-)

Yes, I'm sure that there are also some other leaks around, but I've not read everything yet. :)

Now for some comments:

> The function you're updating here, bamf_application_setup_icon_and_name(),
> seems to leak self->priv->icon right at the end if it's set before we assign
> it. Can you plug that while you're here?

Done. Free'd also on dispose.

> 30 void
> 31 +bamf_legacy_screen_inject_window (BamfLegacyScreen *self, guint xid)
>
> It's not totally clear to me what this function is intended to do. Can you add
> a short docstring? (I assume most ppl wont bother to dig out of the revision
> history like me ;-))

Done.

> 94 +void
> 95 +bamf_legacy_window_reopen (BamfLegacyWindow *self)
>
> Same as the last new function :-)

Done.

> 101 + g_object_weak_ref (G_OBJECT (self), (GWeakNotify)
> handle_destroy_notify,
> 102 + GUINT_TO_POINTER (xid));
>
> It's not very clear what the magic behind this weak ref is, could you add an
> explanatory comment?

Ok.

> 373 + g_list_free_full (possible_apps, g_free);
>
> The introduction of g_list_free_full() is nice, but requires glib >=2.28.
> Please add that check to configure.in.

Done.

> 423 + if (!g_hash_table_lookup (registered_pids, key))
> 424 + {
> 425 + g_hash_table_insert (registered_pids, key, g_strdup (window_hint));
> 426 + }
>
> Only updating if we don't already know the pid seems like it could cause
> things to go askew? If that's not the case I think this logic requires a
> comment in the code.

Well, this code was already there and I just kept the old behavior alive. However it seems to work well, also because generally a pid is always connected to just one application, except particular cases like this one (libreoffice or chromium).
However, I'll study more on this and eventually I'll change this code.

> 628 static void
> 629 +bamf_matcher_dispose (GObject *object)
>
> This function does not look like it's safe to run N times on the same object.
> That is the contract of dispose(). Fx.

Right, moving to finalize().

> The commit message for this chunk mentions that you log a g_critical()when you
> replace an object. I don't see that critical being logged - is that
> intentional?

Ehehe... Really it was there, but I don't know why I've not committed it.
Re-added! ;)

441. By Marco Trevisan (Treviño)

BamfLegacyWindow: added docs to bamf_legacy_window_reopen

442. By Marco Trevisan (Treviño)

BamfMatcher: correctly match the libreoffice transient windows.

We'll use the class name for matching them. This allows to be even more precise.

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

Ok, looking good now. Awesome work! Just one line to fix before I can approve this:

773 + object_class->dispose = bamf_matcher_finalize;

You mean

 + object_class->finalize = bamf_matcher_finalize;

:-)

review: Needs Fixing
443. By Marco Trevisan (Treviño)

BamfMatcher: fixing typo s/dispose/finalize/

Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote :

I am happy! :-D

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches