Fix #98303 and assorted cleanup

2002-11-19  Havoc Pennington  <hp@pobox.com>

        Fix #98303 and assorted cleanup

	* src/prefs.c (meta_preference_to_string): handle
	META_PREF_WORKSPACE_NAMES

	* src/menu.c (get_workspace_name_with_accel): assert that the
	workspace has a name

	* src/screen.c (meta_screen_ensure_workspace_popup): assert that
	we got a workspace name
	(meta_screen_ensure_workspace_popup): assert that we got a
	workspace name

	* src/prefs.c (update_workspace_name): fix screwiness (strcmp with
	a freed string, assorted bad logic)
	(init_workspace_names): assert that we filled in a default
	workspace name
	(meta_prefs_get_workspace_name): assert non-NULL workspace name
This commit is contained in:
Havoc Pennington 2002-11-20 03:57:20 +00:00 committed by Havoc Pennington
parent bd537dcfc6
commit 2541da1d83
4 changed files with 50 additions and 8 deletions

View File

@ -1,3 +1,24 @@
2002-11-19 Havoc Pennington <hp@pobox.com>
Fix #98303 and assorted cleanup
* src/prefs.c (meta_preference_to_string): handle
META_PREF_WORKSPACE_NAMES
* src/menu.c (get_workspace_name_with_accel): assert that the
workspace has a name
* src/screen.c (meta_screen_ensure_workspace_popup): assert that
we got a workspace name
(meta_screen_ensure_workspace_popup): assert that we got a
workspace name
* src/prefs.c (update_workspace_name): fix screwiness (strcmp with
a freed string, assorted bad logic)
(init_workspace_names): assert that we filled in a default
workspace name
(meta_prefs_get_workspace_name): assert non-NULL workspace name
2002-11-16 Bill Haneman <bill.haneman@sun.com> 2002-11-16 Bill Haneman <bill.haneman@sun.com>
* src/themes/Atlanta/metacity-theme-1.xml: * src/themes/Atlanta/metacity-theme-1.xml:

View File

@ -141,6 +141,8 @@ get_workspace_name_with_accel (Display *display,
name = meta_core_get_workspace_name_with_index (display, xroot, index); name = meta_core_get_workspace_name_with_index (display, xroot, index);
g_assert (name != NULL);
/* /*
* If the name is of the form "Workspace x" where x is an unsigned * If the name is of the form "Workspace x" where x is an unsigned
* integer, insert a '_' before the number if it is less than 10 and * integer, insert a '_' before the number if it is less than 10 and

View File

@ -1137,6 +1137,10 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_BUTTON_LAYOUT: case META_PREF_BUTTON_LAYOUT:
return "BUTTON_LAYOUT"; return "BUTTON_LAYOUT";
break; break;
case META_PREF_WORKSPACE_NAMES:
return "WORKSPACE_NAMES";
break;
} }
return "(unknown)"; return "(unknown)";
@ -1342,6 +1346,8 @@ init_workspace_names (void)
update_workspace_name (key, str_val); update_workspace_name (key, str_val);
g_assert (workspace_names[i] != NULL);
g_free (str_val); g_free (str_val);
g_free (key); g_free (key);
@ -1553,21 +1559,23 @@ update_workspace_name (const char *name,
return FALSE; return FALSE;
} }
if ((workspace_names[i] == NULL && value == NULL) || if (workspace_names[i] && value && strcmp (workspace_names[i], value) == 0)
(workspace_names[i] && value && strcmp (workspace_names[i], value) == 0))
{ {
meta_topic (META_DEBUG_PREFS, meta_topic (META_DEBUG_PREFS,
"Workspace name %d is unchanged\n", i); "Workspace name %d is unchanged\n", i);
return FALSE; return FALSE;
} }
g_free (workspace_names[i]);
if (value != NULL) if (value != NULL)
{
g_free (workspace_names[i]);
workspace_names[i] = g_strdup (value); workspace_names[i] = g_strdup (value);
}
else else
{ {
/* use a default name */ /* use a default name */
char *d; char *d;
d = g_strdup_printf (_("Workspace %d"), i + 1); d = g_strdup_printf (_("Workspace %d"), i + 1);
if (workspace_names[i] && strcmp (workspace_names[i], d) == 0) if (workspace_names[i] && strcmp (workspace_names[i], d) == 0)
{ {
@ -1576,6 +1584,7 @@ update_workspace_name (const char *name,
} }
else else
{ {
g_free (workspace_names[i]);
workspace_names[i] = d; workspace_names[i] = d;
} }
} }
@ -1592,6 +1601,8 @@ meta_prefs_get_workspace_name (int i)
{ {
g_return_val_if_fail (i >= 0 && i < MAX_REASONABLE_WORKSPACES, NULL); g_return_val_if_fail (i >= 0 && i < MAX_REASONABLE_WORKSPACES, NULL);
g_assert (workspace_names[i] != NULL);
return workspace_names[i]; return workspace_names[i];
} }

View File

@ -1137,6 +1137,9 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[iter].key = (MetaTabEntryKey) workspace; entries[iter].key = (MetaTabEntryKey) workspace;
entries[iter].title = meta_workspace_get_name (workspace); entries[iter].title = meta_workspace_get_name (workspace);
entries[iter].icon = NULL; entries[iter].icon = NULL;
g_assert (entries[iter].title != NULL);
iter++; iter++;
} }
} }
@ -1156,6 +1159,8 @@ meta_screen_ensure_workspace_popup (MetaScreen *screen)
entries[i].key = (MetaTabEntryKey) workspace; entries[i].key = (MetaTabEntryKey) workspace;
entries[i].title = meta_workspace_get_name (workspace); entries[i].title = meta_workspace_get_name (workspace);
entries[i].icon = NULL; entries[i].icon = NULL;
g_assert (entries[i].title != NULL);
} }
} }
@ -1462,6 +1467,9 @@ meta_screen_update_workspace_names (MetaScreen *screen)
i = 0; i = 0;
while (i < n_names) while (i < n_names)
{ {
meta_topic (META_DEBUG_PREFS,
"Setting workspace %d name to \"%s\" due to _NET_DESKTOP_NAMES change\n",
i, names[i] ? names[i] : "null");
meta_prefs_change_workspace_name (i, names[i]); meta_prefs_change_workspace_name (i, names[i]);
++i; ++i;