[Geany-Devel] Problem with a plugin I'm working on

Nick Treleaven nick.treleaven at xxxxx
Wed Apr 3 13:08:44 UTC 2013

On 02/04/2013 22:53, Steven Blatnick wrote:
> I've started writing some plugins for geany on github, but I'm running
> into a problem.  C is not my language of expertise, so I thought I would
> see if I'm just doing something stupid.
> *The Problem:*
> The basic problem is that I have a struct I'm using to pass information
> around like an object, but the information isn't staying with the struct
> when retrieving it from a TreeView.

I think the problem is this line:
	list = gtk_tree_store_new(1, G_TYPE_STRING);


Tool *tool
gtk_tree_store_set(list, &row, 0, tool, -1);

You should probably be using G_TYPE_POINTER instead of G_TYPE_STRING.


"G_TYPE_STRING - stores a string in the store (makes a copy of the 
original string)
G_TYPE_POINTER - stores a pointer value (does not copy any data into the 
store, just stores the pointer value!)"

> Also, one of the things I love about Geany is how little memory it uses,
> so feel free to give me pointers on when I need to free up memory,
> because I don't want my code to leak.

Well, I didn't study your code for long, but:
Tool *tool = g_slice_new(Tool);

Somehow you need to g_slice_free(Tool, tool) for each call to 
g_slice_new. Maybe by iterating the tree store when you've finished 
using it.

More information about the Devel mailing list