Commit 51583b2a authored by Scott Reeves's avatar Scott Reeves

Various memory leak and array bounds overwrite fixes.

Check properly for g-m-m with version-2 changes

svn path=/trunk/; revision=218
parent 3501b11e
2007-03-08 Scott Reeves <sreeves@novell.com>
* main-menu/src/main-menu-ui.c
* main-menu/src/bookmark-tile-table.c
* libslab/application-tile.c
* libslab/slab-gnome-util.c
* libslab/nameplate-tile.c
* libslab/slab-gnome-util.h
* libslab/nameplate-tile.h
* libslab/libslab-utils.c
* libslab/directory-tile.c
* libslab/document-tile.c
* libslab/document-tile.h:
Various memory leak and array bounds overwrite fixes.
Check properly for g-m-m with version-2 changes
2007-02-28 Jim Krehl <jimmyk@novell.com>
* libslab/document-tile.c
* libslab/directory-tile.c:
......
......@@ -396,10 +396,11 @@ application_tile_setup (ApplicationTile *this, const gchar *gconf_prefix)
else
use_new_prefix = FALSE;
/* see if g-m-m is installed */
if(!use_new_prefix)
key = SLAB_USER_SPECIFIED_APPS_KEY;
key = SLAB_URGENT_CLOSE_KEY;
else
key = "/apps/main-menu/file-area/user_specified_apps";
key = "/apps/main-menu/urgent_close";
if ((list = get_slab_gconf_slist (key))) {
free_slab_gconf_slist_of_strings (list);
......@@ -537,32 +538,35 @@ add_to_user_list (ApplicationTile *this)
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
tiles = libslab_get_user_app_uris ();
if (! g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp)) {
tiles = g_list_append (tiles, TILE (this)->uri);
tiles = g_list_append (tiles, g_strdup (TILE (this)->uri));
libslab_save_app_uris (tiles);
}
priv->is_in_user_list = TRUE;
g_list_free (tiles);
if (tiles)
free_list_of_strings (tiles);
}
static void
remove_from_user_list (ApplicationTile *this)
{
ApplicationTilePrivate *priv = APPLICATION_TILE_GET_PRIVATE (this);
GList *tiles;
GList *tiles, *item;
tiles = libslab_get_user_app_uris ();
tiles = g_list_remove_link (tiles, g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp));
item = g_list_find_custom (tiles, TILE (this)->uri, (GCompareFunc) libslab_strcmp);
tiles = g_list_remove_link (tiles, item);
libslab_save_app_uris (tiles);
priv->is_in_user_list = FALSE;
g_list_free (tiles);
if (item)
free_list_of_strings (item);
if (tiles)
free_list_of_strings (tiles);
}
static void
......
......@@ -148,6 +148,8 @@ directory_tile_new (const gchar *in_uri, const gchar *title, const gchar *icon_n
NULL);
g_free (uri);
if (tooltip_text)
g_free (tooltip_text);
priv = DIRECTORY_TILE_GET_PRIVATE (this);
priv->basename = g_strdup (basename);
......
......@@ -183,8 +183,8 @@ document_tile_new (const gchar *in_uri, const gchar *mime_type, time_t modified)
document_tile_private_setup (this);
TILE (this)->actions = g_new0 (TileAction *, 6);
TILE (this)->n_actions = 6;
TILE (this)->actions = g_new0 (TileAction *, DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS);
TILE (this)->n_actions = DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS;
menu_ctnr = GTK_CONTAINER (TILE (this)->context_menu);
......
......@@ -49,6 +49,7 @@ typedef struct {
#define DOCUMENT_TILE_ACTION_DELETE 4
#define DOCUMENT_TILE_ACTION_UPDATE_MAIN_MENU 5
#define DOCUMENT_TILE_ACTION_SEND_TO 6
#define DOCUMENT_TILE_ACTION_NUM_OF_ACTIONS 7 /* must be last entry and equal to the number of actions */
GType document_tile_get_type (void);
......
......@@ -1001,6 +1001,8 @@ get_data_file_path (const gchar *filename, gboolean writeable)
if (g_file_test (path, G_FILE_TEST_EXISTS))
return path;
g_free (path);
}
sys_dirs = g_get_system_data_dirs ();
......
......@@ -117,8 +117,6 @@ nameplate_tile_constructor (GType type, guint n_param, GObjectConstructParam * p
static void
nameplate_tile_finalize (GObject * g_object)
{
g_free (NAMEPLATE_TILE (g_object)->tooltip);
(*G_OBJECT_CLASS (nameplate_tile_parent_class)->finalize) (g_object);
}
......@@ -126,6 +124,7 @@ static void
nameplate_tile_get_property (GObject * g_object, guint prop_id, GValue * value,
GParamSpec * param_spec)
{
GtkTooltipsData *tooltip;
NameplateTile *np_tile = NAMEPLATE_TILE (g_object);
switch (prop_id)
......@@ -142,7 +141,8 @@ nameplate_tile_get_property (GObject * g_object, guint prop_id, GValue * value,
g_value_set_object (value, np_tile->subheader);
break;
case PROP_NAMEPLATE_TOOLTIP:
g_value_set_string (value, np_tile->tooltip);
tooltip = gtk_tooltips_data_get (GTK_WIDGET (np_tile));
g_value_set_string (value, tooltip ? tooltip->tip_text : NULL);
break;
default:
......@@ -158,8 +158,7 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v
NameplateTilePrivate *priv = NAMEPLATE_TILE_GET_PRIVATE (this);
GObject *widget_obj = NULL;
gchar *tooltip = NULL;
const gchar *tooltip = NULL;
switch (prop_id) {
case PROP_NAMEPLATE_IMAGE:
......@@ -169,7 +168,7 @@ nameplate_tile_set_property (GObject * g_object, guint prop_id, const GValue * v
break;
case PROP_NAMEPLATE_TOOLTIP:
tooltip = g_value_dup_string (value);
tooltip = g_value_get_string (value);
break;
default:
......
......@@ -40,7 +40,6 @@ typedef struct {
GtkWidget *image;
GtkWidget *header;
GtkWidget *subheader;
gchar *tooltip;
} NameplateTile;
typedef struct {
......
......@@ -87,6 +87,17 @@ get_slab_gconf_string (const gchar * key)
return value;
}
void
free_list_of_strings (GList * string_list)
{
GList * temp;
g_assert (string_list != NULL);
for(temp = string_list; temp; temp = temp->next)
g_free (temp->data);
g_list_free (string_list);
}
void
free_slab_gconf_slist_of_strings (GSList * string_list)
{
......
......@@ -48,6 +48,7 @@ gboolean get_slab_gconf_bool (const gchar * key);
gint get_slab_gconf_int (const gchar * key);
GSList *get_slab_gconf_slist (const gchar * key);
void free_slab_gconf_slist_of_strings (GSList * list);
void free_list_of_strings (GList * list);
gchar *get_slab_gconf_string (const gchar * key);
GnomeDesktopItem *load_desktop_item_from_gconf_key (const gchar * key);
......
......@@ -254,6 +254,8 @@ update_monitor (BookmarkTileTable *this)
g_free (uri);
}
else
g_free (path);
}
static void
......
......@@ -249,6 +249,7 @@ main_menu_ui_new (PanelApplet *applet)
priv->main_menu_xml = glade_xml_new (glade_xml_path, "slab-main-menu-window", NULL);
priv->panel_button_xml = glade_xml_new (glade_xml_path, "slab-panel-button-root", NULL);
g_free (glade_xml_path);
create_panel_button (this);
create_slab_window (this);
......@@ -1522,6 +1523,7 @@ slab_window_expose_cb (GtkWidget *widget, GdkEventExpose *event, gpointer user_d
cairo_set_source (cr, gradient);
cairo_fill_preserve (cr);
cairo_pattern_destroy (gradient);
cairo_destroy (cr);
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment