Fix a memory leak in LdDiagramSymbol.

This commit is contained in:
Přemysl Eric Janouch 2011-02-06 17:57:37 +01:00
parent 7f08a51c66
commit 107ec13506
3 changed files with 15 additions and 7 deletions

View File

@ -1022,11 +1022,16 @@ is_object_selected (LdCanvas *self, LdDiagramObject *object)
static LdSymbol *
resolve_diagram_symbol (LdCanvas *self, LdDiagramSymbol *diagram_symbol)
{
LdSymbol *symbol;
gchar *klass;
if (!self->priv->library)
return NULL;
return ld_library_find_symbol (self->priv->library,
ld_diagram_symbol_get_class (diagram_symbol));
klass = ld_diagram_symbol_get_class (diagram_symbol);
symbol = ld_library_find_symbol (self->priv->library, klass);
g_free (klass);
return symbol;
}
static gboolean
@ -1789,8 +1794,11 @@ draw_symbol (LdDiagramSymbol *diagram_symbol, DrawData *data)
/* TODO: Resolve this better; draw a cross or whatever. */
if (!symbol)
{
g_warning ("cannot find symbol `%s' in the library",
ld_diagram_symbol_get_class (diagram_symbol));
gchar *klass;
klass = ld_diagram_symbol_get_class (diagram_symbol);
g_warning ("cannot find symbol `%s' in the library", klass);
g_free (klass);
return;
}

View File

@ -116,10 +116,10 @@ ld_diagram_symbol_new (JsonObject *storage)
*
* Return value: the class of the symbol.
*/
const gchar *
gchar *
ld_diagram_symbol_get_class (LdDiagramSymbol *self)
{
const gchar *klass;
gchar *klass;
g_return_val_if_fail (LD_IS_DIAGRAM_SYMBOL (self), NULL);
g_object_get (self, "class", &klass, NULL);

View File

@ -53,7 +53,7 @@ struct _LdDiagramSymbolClass
GType ld_diagram_symbol_get_type (void) G_GNUC_CONST;
LdDiagramSymbol *ld_diagram_symbol_new (JsonObject *storage);
const gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
gchar *ld_diagram_symbol_get_class (LdDiagramSymbol *self);
void ld_diagram_symbol_set_class (LdDiagramSymbol *self, const gchar *klass);