gtk+-3.18.1/examples/application10 question

2015-10-14 Thread Stefan Salewski
gtk+-3.18.1/examples/application10

cd application10
glib-compile-schemas .
glib-compile-resources exampleapp.gresource.xml --target=resources.c 
--generate-source
gcc -o main main.c resources.c exampleapp.c exampleappwin.c exampleappprefs.c 
`pkg-config --libs --cflags gtk+-3.0`

I am still trying to fully understand the application10 code.
I inserted a printf call as below.

static void
example_app_prefs_dispose (GObject *object)
{
  ExampleAppPrefsPrivate *priv;
  printf("called example_app_prefs_dispose()\n");

When I open the preferences dialog window and close it again, above func
tion is called twice. 

./main exampleapp.c
called example_app_prefs_dispose()
called example_app_prefs_dispose()

Is that really desired, and why does it happen?


___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: gtk+-3.18.1/examples/application10 question

2015-10-14 Thread Emmanuele Bassi
Hi;

On 14 October 2015 at 16:50, Stefan Salewski  wrote:
> gtk+-3.18.1/examples/application10
>
> cd application10
> glib-compile-schemas .
> glib-compile-resources exampleapp.gresource.xml --target=resources.c 
> --generate-source
> gcc -o main main.c resources.c exampleapp.c exampleappwin.c exampleappprefs.c 
> `pkg-config --libs --cflags gtk+-3.0`

You can use the `Makefile.example` file instead.

> I am still trying to fully understand the application10 code.

This is more of an issue you have with GObject.

> When I open the preferences dialog window and close it again, above func
> tion is called twice.
>
> ./main exampleapp.c
> called example_app_prefs_dispose()
> called example_app_prefs_dispose()
>
> Is that really desired, and why does it happen?

GObject::dispose can be called multiple times, because of temporary
vivification or reference cycles. That's the reason why the
finalization step of GObject is split into two — dispose() and
finalize(). See the GObject documentation at:

  https://developer.gnome.org/gobject/stable/howto-gobject-destruction.html

Ciao,
 Emmanuele.

-- 
https://www.bassi.io
[@] ebassi [@gmail.com]
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list