Re: gdk_threads_enter/leave() in threaded and non threaded situation

2005-02-13 Thread Pablo
I use something like this:

#define GLC_THREADS_ENTER(bThread)  if(bThread) \
   gdk_threads_enter()
#define GLC_THREADS_LEAVE(bThread)  if(bThread) \
   gdk_threads_leave()
 
int func(gbooleadn bIsThread)
{
 bla bla bla
GLC_THREADS_ENTER(bIsThread);

// normal gdk_thread_enter/leave here

GLC_THREADS_LEAVE(bIsThread);

return 0;
}

Saludos. Pablo.

- Original Message - 
From: "Stefan Kost" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, February 10, 2005 6:20 PM
Subject: gdk_threads_enter/leave() in threaded and non threaded situation


hi hi,

I have a gobject property that is set (via g_object_set()) from within a 
thread and from the main thread.
Further I have signal handlers that watch this via notify::property.
These signal handler call gtk functions. Therefore in these signal 
handlers the gtk part is wrapped with gdk_threads_enter/leave().
When the singnal is triggered from the thread it works, but when it gets 
triggerd from the main thread gdk_threads_enter blocks.

This is quite obvious, as in this thread I am already in 
gdk_threads_enter(). But how should the signal handler know that (wheter 
it has been triggered from the main thread or from another thread)?

#0  0xe410 in ?? ()
#1  0xbfffde28 in ?? ()
#2  0x0002 in ?? ()
#3  0x in ?? ()
#4  0x403c1cce in __lll_mutex_lock_wait () from /lib/tls/libpthread.so.0
#5  0x403bea4d in _L_mutex_lock_33 () from /lib/tls/libpthread.so.0
#6  0xbfffde34 in ?? ()
#7  0x07735940 in ?? ()
#8  0x40709088 in ?? () from /opt/gnome/lib/libgdk-x11-2.0.so.0
#9  0x0861c4c8 in ?? ()
#10 0x084d46f0 in ?? ()
#11 0xbfffde38 in ?? ()
#12 0x406aed5c in gdk_threads_impl_lock () from 
/opt/gnome/lib/libgdk-x11-2.0.so.0
#13 0x406aed5c in gdk_threads_impl_lock () from 
/opt/gnome/lib/libgdk-x11-2.0.so.0
#14 0x406aece4 in gdk_threads_enter () from 
/opt/gnome/lib/libgdk-x11-2.0.so.0
#15 0x080649c0 in on_sequence_tick (sequence=0x8559940, arg=0x8332d78, 
user_data=0x84d46f0) at main-statusbar.c:78
#16 0x407baf7e in g_cclosure_marshal_VOID__PARAM () from 
/opt/gnome/lib/libgobject-2.0.so.0
#17 0x407acbfb in g_closure_invoke () from 
/opt/gnome/lib/libgobject-2.0.so.0
#18 0x407bdfb0 in signal_emit_unlocked_R () from 
/opt/gnome/lib/libgobject-2.0.so.0
#19 0x407bf68a in g_signal_emit_valist () from 
/opt/gnome/lib/libgobject-2.0.so.0
#20 0x407bf9b2 in g_signal_emit () from /opt/gnome/lib/libgobject-2.0.so.0
#21 0x407b4895 in g_object_dispatch_properties_changed () from 
/opt/gnome/lib/libgobject-2.0.so.0
--
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_message and g_warning under Windows

2005-02-13 Thread Emmanuele Bassi
Hi,

* Tor Lillqvist <[EMAIL PROTECTED]>:

> Russell Shaw writes:
>  > Richard Gipps wrote:
>  > > I notice that under GTK+ 2.6 (in Windows), a call to g_error()
>  > > brings up a dialogue box with the error message,
> 
> Yes, fatal errors do that (before calling abort()). It is somewhat
> debatable, and might get removed in the future. Some application
> developers feel that it's not GLib's business to do any kind of GUI,
> even if just a Win32 MessageBox. 

The solution might be creating an API for a custom error output handler:

typedef void (* GLibErrorHandlerFunc) (GError *error,
   gpointer user_data);

gboolean g_error_set_handler_func (GlibErrorHandlerFunc func,
   gpointer user_data);

Then GTK+ could provide default error handler, e.g. using a MessageBox
on Win32.

Regards,
 Emmanuele.

-- 
Emmanuele Bassi (Zefram) [ http://www.emmanuelebassi.net ]
GnuPG Key fingerprint = 4DD0 C90D 4070 F071 5738  08BD 8ECC DB8F A432 0FF4
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_message and g_warning under Windows

2005-02-13 Thread Tor Lillqvist
Russell Shaw writes:
 > Richard Gipps wrote:
 > > I notice that under GTK+ 2.6 (in Windows), a call to g_error()
 > > brings up a dialogue box with the error message,

Yes, fatal errors do that (before calling abort()). It is somewhat
debatable, and might get removed in the future. Some application
developers feel that it's not GLib's business to do any kind of GUI,
even if just a Win32 MessageBox. 

 > It outputs the message to stderr or stdout 

It does this on Windows, too. But note that in "windowing"
applications (i.e. those linked with the -mwindows flag (GNU tools) or
/subsystem:windows (MSFT)) stderr and stdout aren't connected to
anything (unless you redirect them from the command line, or freopen
them in the application), thus the output typically goes nowhere.

--tml


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk-app-devel-list@gnome.org

2005-02-13 Thread Liam R. E. Quin
On Sun, 2005-02-13 at 18:20 +0100, ALLs soft wrote:
> gtk_label_set_markup (GTK_LABEL (naziv_pjesme), " size=\"xx-large\">Naziv pjesme");
> 
> why i cant print any string with '&'?

The & is special in XML, so you need to escape it.
Either use & or &

Liam

-- 
Liam Quin, W3C XML Activity Lead, http://www.w3.org/People/Quin
Pictures from old books: http://www.holoweb.net/~liam/pictures/oldbooks/
IRC (chat) programs: www.ircreviews.org/clients/

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk-app-devel-list@gnome.org

2005-02-13 Thread ALLs soft
gtk_label_set_markup (GTK_LABEL (naziv_pjesme), "Naziv pjesme");

why i cant print any string with '&'?
like...
gtk_label_set_markup (GTK_LABEL (naziv_pjesme), "Naziv pjesme&&");

string what is sent to show is in UTF8.
thanks.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.8.6 - Release Date: 7.2.2005
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_message and g_warning under Windows

2005-02-13 Thread Russell Shaw
Richard Gipps wrote:
I notice that under GTK+ 2.6 (in Windows), a call to g_error() brings up 
a dialogue box with the error message, but where do the messages 
generated by g_message() and g_warning get piped to?
The log handler can be set with g_log_set_handler(), and defaults
to g_log_default_handler().
This is used if no log handler has been set for the particular log domain and log level combination. 
It outputs the message to stderr or stdout and if the log level is fatal it calls abort().

(from the api manual)
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_ptr_array_sort crash

2005-02-13 Thread Gyözö Both
you were right, the compare function was to blame. the error happened
because two integers that were the same weren't the same after some
transformations to float, so the function didn't return 0, as it should
have. a nasty bug, that one.

gyözö 

> This might be happening because your compare function is inconsistent,
> e.g.  when
> 
>player_compare_func (foo, bar, x)  returns a value < 0
> and
>player_compare_func (bar, foo, x)  returns 0  (instead of a value >
>0)
> 
> or 
>player_compare_func (bar, bar, x)  returns a value != 0  (instead
>of 0)
> 
> or something similar. 
> 
> Cheers
>  -Tim
> 


-- 
Just because your doctor has a name for your condition doesn't mean he
knows what it is.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


g_message and g_warning under Windows

2005-02-13 Thread Richard Gipps
I notice that under GTK+ 2.6 (in Windows), a call to g_error() brings up a 
dialogue box with the error message, but where do the messages generated by 
g_message() and g_warning get piped to?

Richard.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Sorting problem

2005-02-13 Thread Maulet
Hi again.
First of all thanks for the aid with my GtkTreeModelFilter problem.
But... problems don't come alone! and here's another one:
I'm displaying a tree view with two sortable columns.
When I select a row and sort the tree view by clicking in one column 
header, the selected row is always the same (it "follows" the changes in 
the tree view). But when I sort the tree view by clicking in the headers 
of both columns alternatively... the selected row changes!

Here's the code:
---[ begin code ]---
#include 
int main(int argc, char* *argv)
{
   GtkWidget *window, *view;
   GtkListStore *store;
   GtkCellRenderer *cell;
   GtkTreeIter iter;
   GtkTreeViewColumn *column;
   enum { COL_STRING, COL_INT, N_COLS };
   gtk_init(&argc, &argv);
   store = gtk_list_store_new(N_COLS, G_TYPE_STRING, G_TYPE_INT);
   gtk_list_store_append(store, &iter);
   gtk_list_store_set(store, &iter, COL_STRING, "animal", COL_INT, 
2, -1);
   gtk_list_store_append(store, &iter);
   gtk_list_store_set(store, &iter, COL_STRING, "zoo", COL_INT, 0, -1);
   gtk_list_store_append(store, &iter);
   gtk_list_store_set(store, &iter, COL_STRING, "foot", COL_INT, 3, 
-1);

   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
   cell = gtk_cell_renderer_text_new();
   column = gtk_tree_view_column_new_with_attributes("String", 
cell, "text",
 COL_STRING, NULL);
   gtk_tree_view_column_set_sort_column_id(column, COL_STRING);
   gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

   cell = gtk_cell_renderer_text_new();
   column = gtk_tree_view_column_new_with_attributes("Int", cell, 
"text",
 COL_INT, NULL);
   gtk_tree_view_column_set_sort_column_id(column, COL_INT);
   gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);

   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect(window, "destroy", gtk_main_quit, NULL);
   gtk_container_add(GTK_CONTAINER(window), view);
   gtk_widget_show_all(window);
   gtk_main();
}
--[ end code ]--
Thanks!
--
David Rosal i Ricart
<[EMAIL PROTECTED]>
--
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_ptr_array_sort crash

2005-02-13 Thread David Necas (Yeti)
On Sun, Feb 13, 2005 at 12:30:07PM +0100, Gyözö Both wrote:
> this is the valgrind output (with tool memcheck):
> 
> ==6098== Invalid read of size 4
> ==6098==at 0x807AC54: player_compare_func (player.c:393)
>
> ...
> 
> doesn't help me a lot :-(
> 
> > Try valgrind, because this looks like consequences of
> > a memory problem that occurs elsewhere.  There are two
> > common problems it may not catch: overwritten stack and
> > wrong level of indirection (i.e., you used too much &'s
> > somewhere), but chances are it will find that `elsewhere'.

Well, I suppose lines 393-394 and 404 are those where it
crashes `normally', so we've gained no info.

A bug in g_ptr_array_sort() is highly improbable (it's
a tested copy of well-tested glib'c qsort()) so what remains
is to debug your code the hard way.  If the array is ok
before sort starts, something must modify it during that.
You can even print complete array after each compare or
whatever, but the problem is to find where you corrupt the
data, GLib has little to do with it.

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkTreeModelFilter question

2005-02-13 Thread Tim Müller
On Sunday 13 February 2005 13:12, Maulet wrote:

> I'm having problems with GtkTreeModelFilter.
> The following sample program simply builds a window with a tree view
> inside. A tree model filter wraps the tree model of the tree view.
> The filter uses a visible function that always returns FALSE. So no rows
> should be shown...
> But compile and run it, and you'll see the tree view showing the row!
>
> Could anyone explain me where am I wrong?
> ...
> view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
> ...

You are not using the filter model you created. Try 

  view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(filter));

Cheers
 -Tim

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: GtkTreeModelFilter question

2005-02-13 Thread Peter Bloomfield
On 02/13/2005 08:12:52 AM, Maulet wrote:
Hi all,
I'm having problems with GtkTreeModelFilter.
The following sample program simply builds a window with a tree  
view inside. A tree model filter wraps the tree model of the  
tree view. The filter uses a visible function that always  
returns FALSE. So no rows should be shown... But compile and  
run it, and you'll see the tree view showing the row!

Could anyone explain me where am I wrong?
You created the view from the real store instead of the filtered  
model.

Peter
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_ptr_array_sort crash

2005-02-13 Thread Tim Müller
On Sunday 13 February 2005 08:06, Gyözö Both wrote:

> i'm sorting a pointer array and every once in a while i get a segfault.
> i'm checking the pointers before sorting with
> g_ptr_array_sort_with_data, and they are fine. the data i pass, an
> integer (with GINT_TO_POINTER) is also all right.
>
> the crash happens in the compare function, which looks like this:
>   (snip)
>
> i print out the two pointers pl1 and pl2, and mostly they are fine, but
> sometimes one of them looks weird (0x049) and is obviously invalid, so
> i get a segfault when the function tries to access the struct members.
>
> as i said, the pointers in the array are all valid and ok before i call
> g_ptr_array_sort.
>
> i don't have a clue what the problem could be :-( hope you have ideas.

This might be happening because your compare function is inconsistent, e.g. 
when

   player_compare_func (foo, bar, x)  returns a value < 0
and
   player_compare_func (bar, foo, x)  returns 0  (instead of a value > 0)

or 
   player_compare_func (bar, bar, x)  returns a value != 0  (instead of 0)

or something similar. 

Cheers
 -Tim
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


GtkTreeModelFilter question

2005-02-13 Thread Maulet
Hi all,
I'm having problems with GtkTreeModelFilter.
The following sample program simply builds a window with a tree view inside.
A tree model filter wraps the tree model of the tree view.
The filter uses a visible function that always returns FALSE. So no rows
should be shown...
But compile and run it, and you'll see the tree view showing the row!
Could anyone explain me where am I wrong?
--[ begin code ]--
#include 
gboolean func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
{
   return FALSE;
}
int main(int argc, char* *argv)
{
   GtkListStore *store;
   GtkTreeIter iter;
   GtkWidget *view, *window;
   GtkTreeViewColumn *column;
   GtkCellRenderer *cell;
   GtkTreeModel *filter;
   gtk_init(&argc, &argv);
   store = gtk_list_store_new(1, G_TYPE_STRING);
   gtk_list_store_append(store, &iter);
   gtk_list_store_set(store, &iter, 0, "You should not see me!", -1);
   filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(store), NULL);
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter),
 (GtkTreeModelFilterVisibleFunc)func, NULL, NULL);
   view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
   cell = gtk_cell_renderer_text_new();
   column = gtk_tree_view_column_new_with_attributes("Column", cell,
 "text", 0, NULL);
   gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
   g_signal_connect(window, "destroy", gtk_main_quit, NULL);
   gtk_container_add(GTK_CONTAINER(window), view);
   gtk_widget_show_all(window);
   gtk_main();
}
--[ end code ]--
Thanks!
--
David Rosal i Ricart
<[EMAIL PROTECTED]>
--

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_ptr_array_sort crash

2005-02-13 Thread Gyözö Both
this is the valgrind output (with tool memcheck):


==6098== Invalid read of size 4
==6098==at 0x807AC54: player_compare_func (player.c:393)
==6098==by 0x1BD7504D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0 .400.6)
==6098==by 0x1BD50B40: g_ptr_array_sort_with_data (in
/opt/gnome/lib/libglib -2.0.so.0.400.6)
==6098==by 0x805BF3A: game_get_penalty_taker (game.c:200)
==6098==  Address 0x9C61DD78 is not stack'd, malloc'd or (recently)
free'd ==6098== 
==6098== Process terminating with default action of signal 11 (SIGSEGV)
==6098==at 0x807AC54: player_compare_func (player.c:393)
==6098==by 0x1BD7504D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0 .400.6)
==6098==by 0x1BD50B40: g_ptr_array_sort_with_data (in
/opt/gnome/lib/libglib -2.0.so.0.400.6)
==6098==by 0x805BF3A: game_get_penalty_taker (game.c:200)

and this with corecheck:

==6123== Process terminating with default action of signal 11 (SIGSEGV)
==6123==  Access not within mapped region at address 0x881C1614
==6123==at 0x807AC54: player_compare_func (player.c:393)
==6123==by 0x3ADEF04D: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6123==by 0x3ADCAB40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6123==by 0x805BF3A: game_get_penalty_taker (game.c:200)

and addrcheck:

==6138== Invalid read of size 4
==6138==at 0x807AC52: player_compare_func (player.c:394)
==6138==by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138==by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138==by 0x805BF3A: game_get_penalty_taker (game.c:200) ==6138== 
Address 0x34E79174 is 4 bytes before a block of size 64 alloc'd ==6138==
   at 0x341492F4: malloc (in /usr/lib/valgrind/vgpreload_addrcheck.so)
==6138==by 0x34149CF7: realloc (in
/usr/lib/valgrind/vgpreload_addrcheck.so) ==6138==by 0x345B4C10:
g_realloc (in /opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138==by
0x34596E17: g_ptr_array_maybe_expand (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138== 
==6138== Invalid read of size 4
==6138==at 0x807ACAA: player_compare_func (player.c:404)
==6138==by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138==by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138==by 0x805BF3A: game_get_penalty_taker (game.c:200) ==6138== 
Address 0xF is not stack'd, malloc'd or (recently) free'd ==6138== 
==6138== Process terminating with default action of signal 11 (SIGSEGV)
==6138==  Access not within mapped region at address 0xF
==6138==at 0x807ACAA: player_compare_func (player.c:404)
==6138==by 0x345BAE9B: g_qsort_with_data (in
/opt/gnome/lib/libglib-2.0.so.0.400.6) ==6138==by 0x34596B40:
g_ptr_array_sort_with_data (in /opt/gnome/lib/libglib-2.0.so.0.400.6)
==6138==by 0x805BF3A: game_get_penalty_taker (game.c:200)

doesn't help me a lot :-(

gyözö

> On Sun, Feb 13, 2005 at 09:06:50AM +0100, Gyözö Both wrote:
> > i'm sorting a pointer array and every once in a while i get a
> > segfault. i'm checking the pointers before sorting with
> > g_ptr_array_sort_with_data, and they are fine. the data i pass, an
> > integer (with GINT_TO_POINTER) is also all right.
> > 
> > ...
> > 
> > i print out the two pointers pl1 and pl2, and mostly they are fine,
> > but sometimes one of them looks weird (0x049) and is obviously
> > invalid, so i get a segfault when the function tries to access the
> > struct members.
> > 
> > as i said, the pointers in the array are all valid and ok before i
> > call g_ptr_array_sort.
> 
> Try valgrind, because this looks like consequences of
> a memory problem that occurs elsewhere.  There are two
> common problems it may not catch: overwritten stack and
> wrong level of indirection (i.e., you used too much &'s
> somewhere), but chances are it will find that `elsewhere'.
> 
> Yeti
> 
> 
> --
> A: Because it messes up the order in which people normally read text.
> Q: Why is top-posting such a bad thing?
> A: Top-posting.
> Q: What is the most annoying thing on usenet and in e-mail?
> 


-- 
I went to the race track once and bet on a horse that was so good that
it took seven others to beat him!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: g_ptr_array_sort crash

2005-02-13 Thread David Necas (Yeti)
On Sun, Feb 13, 2005 at 09:06:50AM +0100, Gyözö Both wrote:
> i'm sorting a pointer array and every once in a while i get a segfault.
> i'm checking the pointers before sorting with
> g_ptr_array_sort_with_data, and they are fine. the data i pass, an
> integer (with GINT_TO_POINTER) is also all right.
> 
> ...
> 
> i print out the two pointers pl1 and pl2, and mostly they are fine, but
> sometimes one of them looks weird (0x049) and is obviously invalid, so
> i get a segfault when the function tries to access the struct members.
> 
> as i said, the pointers in the array are all valid and ok before i call
> g_ptr_array_sort.

Try valgrind, because this looks like consequences of
a memory problem that occurs elsewhere.  There are two
common problems it may not catch: overwritten stack and
wrong level of indirection (i.e., you used too much &'s
somewhere), but chances are it will find that `elsewhere'.

Yeti


--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


g_ptr_array_sort crash

2005-02-13 Thread Gyözö Both
hi,

i'm sorting a pointer array and every once in a while i get a segfault.
i'm checking the pointers before sorting with
g_ptr_array_sort_with_data, and they are fine. the data i pass, an
integer (with GINT_TO_POINTER) is also all right.

the crash happens in the compare function, which looks like this:

gint
player_compare_func(gconstpointer a, gconstpointer b, gpointer data)
{
const Player *pl1 = *(const Player**)a;
const Player *pl2 = *(const Player**)b;
gint type = GPOINTER_TO_INT(data);

(compare the structs that are pointed to)

}

i print out the two pointers pl1 and pl2, and mostly they are fine, but
sometimes one of them looks weird (0x049) and is obviously invalid, so
i get a segfault when the function tries to access the struct members.

as i said, the pointers in the array are all valid and ok before i call
g_ptr_array_sort.

i don't have a clue what the problem could be :-( hope you have ideas.

gyözö

-- 
No violence, gentlemen -- no violence, I beg of you! Consider
the furniture!
-- Sherlock Holmes
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list