Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: wxWidgets and SFML on Linux(wxGTK)  (Read 4754 times)

0 Members and 2 Guests are viewing this topic.

Ankou

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
wxWidgets and SFML on Linux(wxGTK)
« on: July 19, 2008, 10:09:32 pm »
Hi, I have a little problem with an error that's very hard to debug, because it doesn't occur everytime. It's probably something with Multithreading.
It directly shuts down when the program starts, I think that it's because of something in which sfml is involved, but I can't tell for sure(because I can't find anything out about a randomly occuring problem)

I hope you can help me :/
that's the output
Quote

The program 'HephaistosGameForge' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
  (Details: serial 33 error_code 3 request_code 3 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
Locking assertion failure.  Backtrace:
#0 /usr/lib/libxcb-xlib.so.0 [0x7fd67ac3297c]
#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_lock+0x15) [0x7fd67ac32a15]
#2 /usr/lib/libX11.so.6 [0x7fd67ce3a323]
#3 /usr/lib/libGL.so.1 [0x7fd680e7f0e6]

When I run it with --sync the error never occures!

I can post the sfml code but it's nearly copied out of the tutorial
Code: [Select]

  1 #ifndef SFMLWXSCROLLEDWINDOW_H_INCLUDE
  2 #define SFMLWXSCROLLEDWINDOW_H_INCLUDE
  3
  4 #include <SFML/Graphics.hpp>
  5 #include <wx/wx.h>
  6
  7 class SFMLwxScrolledWindow : public wxScrolledWindow, public sf::RenderWindow
  8   {
  9   public:
 10     SFMLwxScrolledWindow(wxWindow* Parent = NULL, wxWindowID Id = -1, const wxPoint& Position = wxDefaultPosition, const wxSize& Size = wxDefaultSize, long Style = 0);
 11     virtual ~SFMLwxScrolledWindow();
 12   private:
 13     DECLARE_EVENT_TABLE()
 14   };
 15
 16 #endif


  1 #include "SFMLwxScrolledWindow.h"
  2
  3 #ifdef __WXGTK__
  4     #include <gdk/gdkx.h>
  5     #include <gtk/gtk.h>
  6     #include <wx/gtk/win_gtk.h>
  7 #endif
  8
  9 BEGIN_EVENT_TABLE(SFMLwxScrolledWindow, wxScrolledWindow)
 10 END_EVENT_TABLE()
 11
 12
 13 SFMLwxScrolledWindow::SFMLwxScrolledWindow(wxWindow* Parent, wxWindowID Id, const wxPoint& Position, const wxSize& Size, long Style) :
 14   wxScrolledWindow(Parent, Id, Position, Size, Style)
 15   {
 16   #ifdef __WXGTK__
 17     //Get the lowlevel Window
 18     gtk_widget_realize(m_wxwindow);
 19     gtk_widget_set_double_buffered(m_wxwindow, false);
 20     GdkWindow* Win = GTK_PIZZA(m_wxwindow)->bin_window;
 21     XFlush(GDK_WINDOW_XDISPLAY(Win));
 22     sf::RenderWindow::Create(GDK_WINDOW_XWINDOW(Win));
 23   #else
 24     sf::RenderWindow::Create(GetHandle());
 25   #endif
 26   }
 27
 28 SFMLwxScrolledWindow::~SFMLwxScrolledWindow()
 29   {}


I really hope you can help me, because I've completly no idea how I can found the cause of this problem.

Ankou

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
wxWidgets and SFML on Linux(wxGTK)
« Reply #1 on: July 20, 2008, 04:08:49 pm »
okay, I don't know if it is the right backtrace(as I said, I think it's multithreaded, maybe it's not but this would be even stranger)
but I created a full backtrace with the gdb and I think it could be more helpfull
Quote

#0  0x00007f60ac9c3095 in raise () from /lib/libc.so.6
#1  0x00007f60ac9c4af0 in abort () from /lib/libc.so.6
#2  0x00007f60ac9fda7b in ?? () from /lib/libc.so.6
#3  0x00007f60aca0508a in ?? () from /lib/libc.so.6
#4  0x00007f60aca08c1c in free () from /lib/libc.so.6
#5  0x00007f60afc63bf1 in std::_Rb_tree<sf::VideoResource*, sf::VideoResource*, std::_Identity<sf::VideoResource*>, std::less<sf::VideoResource*>, std::allocator<sf::VideoResource*> >::erase () from /usr/lib/libsfml-graphics.so.1
#6  0x00007f60afc63c78 in std::_Rb_tree<sf::VideoResource*, sf::VideoResource*, std::_Identity<sf::VideoResource*>, std::less<sf::VideoResource*>, std::allocator<sf::VideoResource*> >::erase () from /usr/lib/libsfml-graphics.so.1
#7  0x00007f60afc63729 in sf::Renderer::RemoveVideoResource () from /usr/lib/libsfml-graphics.so.1
#8  0x000000000046eb00 in std::_Destroy<sf::Image> (__pointer=0xd76c58) at /usr/include/c++/4.2/bits/stl_construct.h:107
#9  0x000000000046eb1d in std::__destroy_aux<sf::Image*> (__first=0xd76c58, __last=0xd76cc8) at /usr/include/c++/4.2/bits/stl_construct.h:122
#10 0x000000000046eb52 in std::_Destroy<sf::Image*> (__first=0xd76c20, __last=0xd76cc8) at /usr/include/c++/4.2/bits/stl_construct.h:155
#11 0x000000000046eb75 in std::_Destroy<sf::Image*, sf::Image> (__first=0xd76c20, __last=0xd76cc8) at /usr/include/c++/4.2/bits/stl_construct.h:182
#12 0x0000000000470c16 in ~vector (this=0xb25538) at /usr/include/c++/4.2/bits/stl_vector.h:268
#13 0x00000000004740c6 in ~ImageList (this=0xb25430) at Resources/ImageList.h:39
#14 0x0000000000474392 in boost::checked_delete<ImageList> (x=0xb25430) at /usr/include/boost/checked_delete.hpp:34
#15 0x000000000047447d in boost::detail::sp_counted_impl_p<ImageList>::dispose (this=0xb25310) at /usr/include/boost/detail/sp_counted_impl.hpp:79
#16 0x0000000000421fe2 in boost::detail::sp_counted_base::release (this=0xb25310) at /usr/include/boost/detail/sp_counted_base_gcc_x86.hpp:145
#17 0x0000000000422012 in ~shared_count (this=0xa68008) at /usr/include/boost/detail/shared_count.hpp:205
#18 0x000000000042202d in ~shared_ptr (this=0xa68000) at /usr/include/boost/shared_ptr.hpp:131
#19 0x000000000046965a in __tcf_0 () at Resources/ImageList.cpp:12
#20 0x00007f60ac9c6110 in exit () from /lib/libc.so.6
#21 0x00007f60af1f08e1 in ?? () from /usr/lib/libgdk-x11-2.0.so.0
#22 0x00007f60ac3c3b6d in _XError () from /usr/lib/libX11.so.6
#23 0x00007f60ac3cac1a in ?? () from /usr/lib/libX11.so.6
#24 0x00007f60ac3cafa5 in _XReply () from /usr/lib/libX11.so.6
#25 0x00007f60ac3aa4d5 in _XGetWindowAttributes () from /usr/lib/libX11.so.6
#26 0x00007f60ac3aa648 in XGetWindowAttributes () from /usr/lib/libX11.so.6
#27 0x00007f60aff523ba in sf::priv::WindowImplX11::WindowImplX11 () from /usr/lib/libsfml-window.so.1
#28 0x00007f60aff4ec64 in sf::priv::WindowImpl::New () from /usr/lib/libsfml-window.so.1
#29 0x00007f60aff4c397 in sf::Window::Create () from /usr/lib/libsfml-window.so.1
#30 0x000000000047d623 in SFMLwxScrolledWindow (this=0x13fc690, Parent=0x13f7a00, Id=-1, Position=@0xa6c818, Size=@0xa6c810, Style=0) at Mapmaker/SFMLwxScrolledWindow.cpp:22
#31 0x000000000043c33b in Tool (this=0x13fc690, parent=0x13f7a00, id=-1) at Mapmaker/Tool.cpp:13
#32 0x000000000044ac00 in TileableTool (this=0x13fc690, parent=0x13f7a00, id=-1) at Mapmaker/TileableTool.cpp:19
#33 0x000000000044f405 in MappingTool (this=0x13fc690, parent=0x13f7a00, id=-1) at Mapmaker/MappingTool.cpp:14
#34 0x000000000044d422 in MapEditor (this=0x13fa600, parent=0x13f7a00, id=-1) at Mapmaker/MapEditor.cpp:32
#35 0x0000000000442912 in MappingMode (this=0x13f8650, parent=0x13f7a00) at Mapmaker/MappingMode.cpp:7
#36 0x00000000004462bc in Mapmaker (this=0x13f7a00, parent=0xaedf50, id=-1) at Mapmaker/Mapmaker.cpp:65
#37 0x0000000000424cec in GUI::setupMainControls (this=0xaedf50) at Mainwindow/GUI.cpp:189
#38 0x00000000004278c9 in GUI (this=0xaedf50) at Mainwindow/GUI.cpp:72
#39 0x00000000004218cd in Application::OnInit (this=0xaa7110) at Main.cpp:22
#40 0x0000000000421704 in wxAppConsole::CallOnInit (this=0xaa7110) at ./include/wx/app.h:76
#41 0x000000000060ec0f in wxEntry (argc=@0xa766f0, argv=0xa94aa0) at ./src/common/init.cpp:440
#42 0x000000000060ee3a in wxEntry (argc=@0x7fffb85748ec, argv=0x7fffb85749d8) a

As you can see those functions are called by sf::Window::Create()

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
wxWidgets and SFML on Linux(wxGTK)
« Reply #2 on: July 20, 2008, 05:10:39 pm »
You're right, this is going to help me a lot :)

Thanks, I'll let you know if I can find the origin of the problem.
Laurent Gomila - SFML developer

Ankou

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
wxWidgets and SFML on Linux(wxGTK)
« Reply #3 on: July 20, 2008, 06:09:22 pm »
But as I said, the backtrace is odd.
For Example this one(sorry, but I haven't seen it before)
Quote
#13 0x00000000004740c6 in ~ImageList (this=0xb25430) at Resources/ImageList.h:39

is a class of mine but the destructor can't be responsible because
1) it's a Singleton, therefore it can't be destroyed before the program is exiting.
2) it only has a default destructor.(line 39 is the opening bracket of the class)
The class is not event deriving from another and no class is deriving from it.
By the way it's a class that also holds sfml Images and Sprites(as well as wxWidgets Images and Bitmaps) but these Sprites are not used anywhere else. And without the class described in the first post everything works fine

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
wxWidgets and SFML on Linux(wxGTK)
« Reply #4 on: July 21, 2008, 03:09:45 am »
I think we can stop on this line :
Quote
#26 0x00007f60ac3aa648 in XGetWindowAttributes () from /usr/lib/libX11.so.6

Then it calls exit() and all your destructors are called. But the actuall error is there, in the WindowImplX11 constructor.
Laurent Gomila - SFML developer