GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

gtk_window_move causes segmentation fault

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Mr. Ego



Joined: 20 May 2007
Posts: 3

PostPosted: Sun May 20, 2007 10:54 am    Post subject: gtk_window_move causes segmentation fault Reply with quote

Hello,
I'm writing small demo application to test moving a window. I use C, GObject, and GTK+.

My source code is here:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#include <gtk/gtk.h>

int
main (int argc, char **argv)
{
  g_type_init();
  GtkWindow *mainwin;
  gtk_set_locale ();
  gtk_init (&argc, &argv);

  mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_show_all (GTK_WIDGET(mainwin));
  gtk_window_move (mainwin, 100, 100);
  gtk_main ();
  return 0;
}

Call for function gtk_window_move causes segmentation fault. Could it be caused by improper GObject use?

Thanks
Back to top
deusvede
Familiar Face


Joined: 13 Feb 2007
Posts: 29
Location: Madrid, Spain

PostPosted: Sun May 20, 2007 11:39 am    Post subject: Reply with quote

You should make 'mainwindow' a GtkWidget pointer instead of a GtkWindow one, and then cast it to a GTK_WINDOW when you call gtk_window_move. But, aside from that, your code runs well on my machine.
Back to top
Mr. Ego



Joined: 20 May 2007
Posts: 3

PostPosted: Sun May 20, 2007 12:19 pm    Post subject: Reply with quote

Thank you. That is strange. I use CMake for setting compiler and linker options and I had to add reference to gtk-x11-2.0 library manually.

Could you please post ldd output with my program? Perhaps I link with bad library. :(
Back to top
Mr. Ego



Joined: 20 May 2007
Posts: 3

PostPosted: Sun May 20, 2007 12:49 pm    Post subject: Reply with quote

I got it working using compiler optins generated by pkgconfig. It looks like an error in CMake configuration script. Thanks. :)
Back to top
deusvede
Familiar Face


Joined: 13 Feb 2007
Posts: 29
Location: Madrid, Spain

PostPosted: Sun May 20, 2007 2:48 pm    Post subject: Reply with quote

You're welcome :).
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP