Merge lp:~hikiko/unity-control-center/unity-control-center.race-cond-empty-monitor-name into lp:unity-control-center

Proposed by Eleni Maria Stea
Status: Merged
Merged at revision: 12732
Proposed branch: lp:~hikiko/unity-control-center/unity-control-center.race-cond-empty-monitor-name
Merge into: lp:unity-control-center
Diff against target: 47 lines (+14/-4)
1 file modified
panels/display/cc-display-panel.c (+14/-4)
To merge this branch: bzr merge lp:~hikiko/unity-control-center/unity-control-center.race-cond-empty-monitor-name
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Sebastien Bacher Pending
Review via email: mp+207974@code.launchpad.net

Commit message

fixed race condition when the monitor is not detected correctly (and the monitor name is null)
added a mark in 1.0 (default value)

Description of the change

fixed race condition when the monitor is not detected correctly (and the monitor name is null)
added a mark in 1.0 (default value)

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work! Some review comments

* > g_warning ("Invalid dictionary entry.\n");

the "\n" is not needed with g_warning

While you are doing some code cleaning, desrt pointed those on IRC:

* add_dict_entry(),

" g_variant_get_child (tmp, 0, "s", &str);
    if (!str)
    {
      fprintf (stderr, "Invalid dictionary entry\n");"

that case can be dropped, it's not possible for str to be null

- the malloc() uses should be replaced by g_new(), the function leaks the result

Could you fix at least the warnings? The other comments can be addressed later in another merge then if you prefer to handle cleanups separatly

Revision history for this message
Sebastien Bacher (seb128) wrote :

(we agreed to land what is in this mp, once the g_warning are changed, and do the other changes in a followup merge request)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

thanks a lot for the review, I ll propose a new branch with the fixes above in a while!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'panels/display/cc-display-panel.c'
2--- panels/display/cc-display-panel.c 2014-02-20 21:17:51 +0000
3+++ panels/display/cc-display-panel.c 2014-02-24 16:59:15 +0000
4@@ -595,7 +595,7 @@
5 g_variant_get_child (tmp, 0, "s", &str);
6 if (!str)
7 {
8- fprintf (stderr, "Invalid dictionary entry\n");
9+ g_warning ("Invalid dictionary entry.\n");
10 break;
11 }
12
13@@ -619,14 +619,18 @@
14
15 GVariant *dict;
16
17+ GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE(self->priv->ui_scale));
18 const char *monitor_name = gnome_rr_output_info_get_name (self->priv->current_output);
19-
20- GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE(self->priv->ui_scale));
21+ if (!monitor_name)
22+ {
23+ g_warning("Failed to get monitor name.\n");
24+ return;
25+ }
26
27 gtk_adjustment_set_upper (adj, UI_SCALE_MAX);
28 gtk_adjustment_set_lower (adj, UI_SCALE_MIN);
29-
30 gtk_scale_set_digits (GTK_SCALE(self->priv->ui_scale), 0);
31+ gtk_scale_add_mark (GTK_SCALE(self->priv->ui_scale), 8, GTK_POS_TOP, NULL);
32
33 g_settings_get (self->priv->desktop_settings, "scale-factor", "@a{si}", &dict);
34 if (!g_variant_lookup (dict, monitor_name, "i", &value))
35@@ -1048,6 +1052,12 @@
36 GVariant *dict;
37
38 monitor_name = gnome_rr_output_info_get_name (self->priv->current_output);
39+ if (!monitor_name)
40+ {
41+ g_warning("Failed to get monitor name.\n");
42+ return FALSE;
43+ }
44+
45 g_settings_get (self->priv->desktop_settings, "scale-factor", "@a{si}", &dict);
46 dict = add_dict_entry (dict, monitor_name, value);
47 g_settings_set (self->priv->desktop_settings, "scale-factor", "@a{si}", dict);

Subscribers

People subscribed via source and target branches