Re: gtk_builder_add_from_file error handling



GError *err = NULL;
if (!gtk_builder_add_from_file(builder_, "myfile.xml", &err)) {
   if (err) {
      g_free(err); // commenting this solves the crash but other gtk apis

I don't know gtkmm, but at least in C GErrors are freed with
g_error_free(err).


You are obviously right. I always used g_free() to free errors, my fault.
I've grepped tons of sources and I had everywhere the code bugged, then I
googled around to search some more examples and I've found there are a lot
of other sources in the net where a GError is freed with g_free, I think
improving the documentation of the functions that use a GError as input
parameter may help programmers do not write wrong code in this situation.

-- 
Bye,
 Gabry



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]