Re: GTK+ and my port of AMP for Windows



The window is created and I can interact without problem with it.
Now, here you are another little test programme that does not work:

It *does* work for me, both when running against GTK+ 2.20.1 and
2.22.0. (The "official" binaries from www.gtk.org, actually hosted on
ftp.gnome.org.)

Âwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);

You really should add here:

 g_signal_connect_swapped(G_OBJECT(window), "destroy",
                          G_CALLBACK(gtk_main_quit), G_OBJECT(window));

(or something to the same effect; there are several ways to do it) so
that the program ends when the window is closed.

(This is not to be related to the problem you are seeing, the program
worked for me even if I didn't add this, the problem then was just
that when I closed the window the program didn't exit.)

The window is created, it's visible on the screen but it's "freezed", I cannot
interact with it and its content is never updated (the busy cursor is always
shown on top of the window).

Sorry, but I don't see this happening.

Have you an idea about what's wrong with this piece of code?

There is nothing wrong as such, but as you can't use GTK+ from
multiple threads on Windows, so there is no point in calling
gdk_threads_init().

After some researches, I discovered that all the problems were resolved by
commenting the call to gdk_threads_init() on top of the main() function.

Well, for me it makes no difference whether it is called or not.

Note that a real, more complex, program that attempts to call GTK+
functions from multiple threads on Windows will certainly not work. It
will deadlock or just not do the right thing. And as you shouldn't be
calling GTK+ from multiple threads if you want the program to work on
Windows, there is no point in calling any gdk_threads_* functions
either.

Note that it's just GTK+ which is problematic from multiple threads on
Windows, GLib functions work as expected from multiple threads.

And in any case, as far as I understand, the majority of experts say
that one shouldn't be using GTK+ from multiple threads even on X11 (in
practice, that means "Linux" for most), because it is so hard to get
right. Instead, use g_idle_add() etc to schedule GTK+ -using functions
to be called from the "main" thread.

I compiled myself the GLib, GTK+ and all other required libraries.
Initially, I though there was something wrong in my libs, so I downloaded all
the zip files with precompiled GTK+ for Windows from GTK+ homepage.
Nothing changed: I got the same results I'm having with my libraries
(hopefully!).

Are you sure you are really running against the official binaries?
Please double-check, for instance by using Process Explorer from
http://technet.microsoft.com/en-gb/sysinternals/default.aspx , that
the DLLs used by the process are actually the ones you think.

--tml



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