aboutsummaryrefslogtreecommitdiffstats
path: root/main/mousepad/Fixup-some-warnings-about-using-NULL-where-it-shoudnt-be.patch
blob: 60fe03c1240f70a67b5f0f96714712f0aca95af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 73c93369f7708ab89c46e67e7933b835aafa6811 Mon Sep 17 00:00:00 2001
From: Matthew Brush <matt@xfce.org>
Date: Wed, 8 Jul 2015 21:03:33 -0700
Subject: Fixup some warnings about using NULL where it shouldn't be

Closes #11663

diff --git a/mousepad/mousepad-action-group.c b/mousepad/mousepad-action-group.c
index 71b37f2..acea132 100644
--- a/mousepad/mousepad-action-group.c
+++ b/mousepad/mousepad-action-group.c
@@ -283,7 +283,8 @@ void
 mousepad_action_group_set_active_style_scheme (MousepadActionGroup  *self,
                                                GtkSourceStyleScheme *scheme)
 {
-  GtkAction *action;
+  GtkAction   *action;
+  const gchar *scheme_name = NULL;
 
   g_return_if_fail (MOUSEPAD_IS_ACTION_GROUP (self));
 
@@ -303,8 +304,11 @@ mousepad_action_group_set_active_style_scheme (MousepadActionGroup  *self,
   self->locked = FALSE;
 
   /* update the setting when the active action is changed */
+  if (scheme != NULL)
+    scheme_name = gtk_source_style_scheme_get_id(scheme);
+
   self->locked = TRUE;
-  MOUSEPAD_SETTING_SET_STRING (COLOR_SCHEME, gtk_source_style_scheme_get_id (scheme));
+  MOUSEPAD_SETTING_SET_STRING (COLOR_SCHEME, scheme_name);
   self->locked = FALSE;
 
   g_object_notify (G_OBJECT (self), "active-style-scheme");
diff --git a/mousepad/mousepad-settings.c b/mousepad/mousepad-settings.c
index 13cead5..4c2f5bc 100644
--- a/mousepad/mousepad-settings.c
+++ b/mousepad/mousepad-settings.c
@@ -298,7 +298,7 @@ void
 mousepad_setting_set_string (const gchar *path,
                              const gchar *value)
 {
-  mousepad_setting_set (path, "s", value);
+  mousepad_setting_set (path, "s", value != NULL ? value : "");
 }
 
 
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index 8c3eba6..bd0e37c 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -257,7 +257,8 @@ mousepad_view_buffer_changed (MousepadView *view,
       GtkSourceStyleScheme        *scheme;
 
       manager = gtk_source_style_scheme_manager_get_default ();
-      scheme = gtk_source_style_scheme_manager_get_scheme (manager, view->color_scheme);
+      scheme = gtk_source_style_scheme_manager_get_scheme (manager,
+        view->color_scheme ? view->color_scheme : "");
       gtk_source_buffer_set_style_scheme (buffer, scheme);
 
       gtk_source_buffer_set_highlight_matching_brackets (buffer, view->match_braces);
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index f1acc2b..adae7cd 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -717,12 +717,13 @@ mousepad_window_action_group_style_scheme_changed (MousepadWindow      *window,
                                                    MousepadActionGroup *group)
 {
   GtkSourceStyleScheme *scheme;
-  const gchar          *scheme_id;
+  const gchar          *scheme_id = NULL;
   gint                  npages, i;
 
   /* get the new active language */
   scheme = mousepad_action_group_get_active_style_scheme (group);
-  scheme_id = gtk_source_style_scheme_get_id (scheme);
+  if (scheme != NULL)
+    scheme_id = gtk_source_style_scheme_get_id (scheme);
 
   /* update the color scheme on all the documents */
   npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
-- 
cgit v0.10.1