You forgot to call g_type_init()

这是wxWidgets论坛的中文版本。在这里,您可以用您的母语汉语讨论上面任一子论坛所涉及的所有关于wxWidgets的话题。欢迎大家参与到对有价值的帖子的中英互译工作中来!
Post Reply
08S011003
In need of some credit
In need of some credit
Posts: 1
Joined: Tue Dec 25, 2012 9:05 am

You forgot to call g_type_init()

Post by 08S011003 » Tue Dec 25, 2012 9:22 am

本人刚接触wxWidgets,运行一个简单的程序,

Code: Select all

#include <wx/wx.h>

/**
   A frame that contains a text control.
*/
class TextFrame : public wxFrame
{
public:
   /**
      Constructs the text control.
   */
   TextFrame();
private:
   wxTextCtrl* text;
};

/**
   An application that shows a frame with a text control.
*/
class TextApp : public wxApp
{
public:
   /**
      Constructs the frame.
   */
   TextApp();
   /**
      Shows the frame.
      @return true
   */
   virtual bool OnInit();
private:
   TextFrame* frame;
};

DECLARE_APP(TextApp)

IMPLEMENT_APP(TextApp)

TextFrame::TextFrame() 
   : wxFrame(NULL, -1, "TextFrame")
{
   text = new wxTextCtrl(this, -1, "Type some text here!",
      wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
}

TextApp::TextApp()
{
   frame = new TextFrame();
}

bool TextApp::OnInit()
{
   frame->Show(true);
   return true;
}
出现如下错误,

(process:4096): GLib-GObject-CRITICAL **: gtype.c:2710: You forgot to call g_type_init()

(process:4096): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

(process:4096): Gdk-CRITICAL **: IA__gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed
./src/unix/displayx11.cpp(425): assert "dpy" failed in wxClientDisplayRect(): can't be called before initializing the GUI

(process:4096): GLib-GObject-CRITICAL **: gtype.c:2710: You forgot to call g_type_init()

请给予指导。

kipade
Earned some good credits
Earned some good credits
Posts: 118
Joined: Fri Nov 11, 2011 2:45 am
Location: China

Re: You forgot to call g_type_init()

Post by kipade » Wed Dec 26, 2012 8:39 am

Slackware GNU/Linux
wxWidgets-3.0.3

ccnyou
Knows some wx things
Knows some wx things
Posts: 33
Joined: Fri Sep 28, 2012 8:08 am

Re: You forgot to call g_type_init()

Post by ccnyou » Wed Apr 24, 2013 2:07 am

检查你代码中用到的全局变量

Post Reply