(process:3309): GLib-GObject-CRITICAL **: gtype.c:2458: initialization assertion failed, use IA__g_type_init() prior to this function
(process:3309): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed
(process:3309): Gdk-CRITICAL **: gdk_screen_get_rgb_visual: assertion `GDK_IS_SCREEN (screen)' failed
Segmentation fault
This is the default wx-config I use to build
# wx-config --list
Default config is x11univ-ansi-debug-static-2.8
I tried to call gtk_init() before InitEngine and still got a segmentation fault, back traced failed in libxul.so all the time. Is there anyway to solve it?
Here's my code:
- Code: Select all
// Name: myRadioApp.cpp
#include "myRadioFrame.h"
#include "myRadioApp.h"
//#include <gtk/gtk.h>
IMPLEMENT_APP(myRadioApp)
bool myRadioApp::OnInit()
{
/*
#if wxUSE_LIBPNG
wxImage::AddHandler(new wxPNGHandler);
#endif
#if wxUSE_LIBJPEG
wxImage::AddHandler(new wxJPEGHandler);
#endif
#if wxUSE_GIF
wxImage::AddHandler(new wxGIFHandler);
#endif
*/
//gtk_init(0, NULL);
//GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
//gtk_widget_show(window);
wxInitAllImageHandlers();
#if wxUSE_FS_INET && wxUSE_STREAMS && wxUSE_SOCKETS
wxFileSystem::AddHandler(new wxInternetFSHandler);
#endif
//////////////////////// (start) wxWebControl Initialization ////////////////////////
// Locate the XULRunner engine; the following call will look for
// a directory named "xr"
wxString xulrunner_path = FindXulRunner(wxT("xr"));
if (xulrunner_path.IsEmpty())
{
wxMessageBox(wxT("Could not find xulrunner directory"));
return false;
}
// Locate some common paths and initialize the control with
// the plugin paths; add these common plugin directories to
// MOZ_PLUGIN_PATH
wxString program_files_dir;
::wxGetEnv(wxT("ProgramFiles"), &program_files_dir);
if (program_files_dir.Length() == 0 || program_files_dir.Last() != '\\')
program_files_dir += wxT("\\");
wxString dir = program_files_dir;
dir += wxT("Mozilla Firefox\\plugins");
wxWebControl::AddPluginPath(dir);
// to install the flash plugin automatically, if it exists,
// add a path to the flash location; for example, on windows,
// if the system directory is given by system_dir, then, we have:
//
// wxString dir2 = system_dir;
// dir2 += wxT("Macromed\\Flash");
// wxWebControl::AddPluginPath(dir2);
// Finally, initialize the engine; Calling wxWebControl::InitEngine()
// is very important and has to be made before using wxWebControl.
// It instructs wxWebConnect where the xulrunner directory is.
// std::cout << xulrunner_path;
// wxWebControl::InitEngine(wxT("./xr"));
wxWebControl::InitEngine(wxT(xulrunner_path));
//////////////////////// (end) wxWebControl Initialization ////////////////////////
myRadioFrame *radioframe = new myRadioFrame( wxT("My Radio TV Player") );
// gtk_main();
// Problem with generic wxNotebook implementation whereby it doesn't size
// properly unless you set the size again
#if defined(__WXMOTIF__)
int width, height;
frame->GetSize(& width, & height);
frame->SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
#endif
radioframe->Show(true);
return true;
}
wxString FindXulRunner(const wxString& xulrunner_dirname)
{
// get the location of this executable
wxString exe_path = wxStandardPaths::Get().GetExecutablePath();
wxString path_separator = wxFileName::GetPathSeparator();
exe_path = exe_path.BeforeLast(path_separator[0]);
exe_path += path_separator;
wxString path;
// first, check <exe_path>/<xulrunner_path>
path = exe_path + xulrunner_dirname;
if (wxDir::Exists(path))
return path;
// next, check <exe_path>/../<xulrunner_path>
path = exe_path + wxT("..") + path_separator + xulrunner_dirname;
if (wxDir::Exists(path))
return path;
// finally, check <exe_path>/../../<xulrunner_path>
path = exe_path + wxT("..") + path_separator + wxT("..") + path_separator + xulrunner_dirname;
if (wxDir::Exists(path))
return path;
return wxEmptyString;
}
myRadioFrame.cpp
- Code: Select all
#include "myRadioFrame.h"
//#include "myHtmlWindow.h"
//#include "mondrian.xpm"
//#include <wx/file.h>
//#include <wx/process.h>
//#include <stdint.h>
//#include <glib.h>
//#include <gtk/gtk.h>
//#include <vlc/vlc.h>
// myRadioFrame constructor ==> base components in the main frame
myRadioFrame::myRadioFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800,600), wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
{
myradiopanel = NULL;
myradionotebook = NULL;
// set icon image
// SetIcon(wxIcon(mondrian_xpm));
// create main menu bar
wxMenuBar *menuBar = new wxMenuBar();
// create file menu bar
wxMenu *menuFile = new wxMenu;
menuFile->Append(mID_FILE_OPEN, wxT("&Open HTML Page"));
menuFile->Append(wxID_EXIT, wxT("E&xit\tESC"), wxT("Quit!!"));
// create about menu bar
wxMenu *menuHelp = new wxMenu;
menuHelp->Append(wxID_ABOUT, wxT("&About...\tF1"), wxT("Show about Dialog"));
// append menu bars into the main one
menuBar->Append(menuFile, wxT("&File"));
menuBar->Append(menuHelp, wxT("&Help"));
// activate the main menu bar
SetMenuBar(menuBar);
// initialize status bar
CreateStatusBar();
GetStatusBar()->SetStatusText(wxT("Ready"));
// main structure inside the window
// new wxButton(this, cID_PLAY, wxT("PLAY"), wxDefaultPosition, wxDefaultSize);
// new wxButton(this, wxID_CANCEL, wxT("CANCEL"), wxDefaultPosition, wxDefaultSize);
wxBookCtrl *book = new wxBookCtrl(this, wxID_ANY);
// contents in myRadioFrame
/////////////////////////////////////////// contents in page 1
page1panel = new wxPanel(book);
// create the main toolbar for myBrowser
wxAuiToolBar *toolbar = new wxAuiToolBar(page1panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE);
toolbar->SetToolBitmapSize(wxSize(24,24));
toolbar->AddTool(cID_BUTTON_BACK, wxT("Go Back"), wxArtProvider::GetBitmap(wxART_GO_BACK));
toolbar->AddTool(cID_BUTTON_FORWARD, wxT("Go Forward"), wxArtProvider::GetBitmap(wxART_GO_FORWARD));
toolbar->AddTool(cID_BUTTON_GOHOME, wxT("Go Home"), wxArtProvider::GetBitmap(wxART_GO_HOME));
toolbar->Realize();
// myurlbar = new wxComboBox(toolbar, wxID_ANY, wxT(""), wxPoint(0,0), wxSize(600,18));
// myurlbar->Connect(cID_URL, wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(myRadioFrame::OnUrlTextEntered));
// myurlbar->Connect(cID_URL, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(myRadioFrame::OnUrlItemSelected));
// EVT_TEXT_ENTER(cID_URL, myRadioFrame::OnUrlTextEntered)
// EVT_COMBOBOX(cID_URL, myRadioFrame::OnUrlItemSelected)
// toolbar->AddControl(myurlbar, wxT("Location"));
// toolbar->Realize();
// initialize myBrowser
wxWebFrame *myhtmlframe = new wxWebFrame(this, wxID_ANY, wxT("OHNO"));
myhtmlbrowser = new wxWebControl(myhtmlframe, wxID_WEB, wxDefaultPosition, wxDefaultSize);
myhtmlbrowser = new wxWebControl(page1panel, wxID_WEB, wxDefaultPosition, wxDefaultSize);
myframemanager.SetManagedWindow(page1panel);
myframemanager.AddPane(toolbar, wxAuiPaneInfo().Name(wxT("Toolbar")).Caption(wxT("Toolbar")).ToolbarPane().Top().LeftDockable(false).RightDockable(false));
// add the browser to the manager
myframemanager.AddPane(myhtmlbrowser, wxAuiPaneInfo().Name(wxT("Browser")).CenterPane().Show());
// update the wxAUI manager
myframemanager.Update();
wxWebPreferences webprefs = wxWebControl::GetPreferences();
webprefs.SetIntPref(wxT("network.cookie.cookieBehavior"), 0);
webprefs.SetIntPref(wxT("privacy.popups.policy"), 1 );
myuri_home = "http://www.google.com";
myhtmlbrowser->OpenURI(wxT(myuri_home));
book->AddPage(page1panel, wxT("myBrowser"));
/////////////////////////////////////////// contents in page 2
page2panel = new wxPanel(book);
mpframepanel = new wxPanel(page2panel);
mpframepanel->SetBackgroundColour(*wxBLACK);
mybuttonplay = new wxButton(page2panel, cID_BUTTON_PLAY, wxT("PLAY"));
mybuttonpause = new wxButton(page2panel, cID_BUTTON_PAUSE, wxT("PAUSE"));
mybuttonstop = new wxButton(page2panel, cID_BUTTON_STOP, wxT("STOP"));
wxSizer *sz1 = new wxBoxSizer(wxHORIZONTAL);
sz1->Add(mybuttonplay, 1, wxDEFAULT);
sz1->Add(mybuttonpause, 1, wxDEFAULT);
sz1->Add(mybuttonstop, 1, wxDEFAULT);
wxSizer *sz2 = new wxBoxSizer(wxVERTICAL);
sz2->Add(mpframepanel, 3, wxGROW);
sz2->Add(sz1, 0.2, wxDEFAULT);
page2panel->SetSizer(sz2);
mpframepanel = new wxPanel(page2panel);
mpframepanel->SetBackgroundColour(*wxBLACK);
mybuttonplay = new wxButton(page2panel, cID_BUTTON_PLAY, wxT("PLAY"));
mybuttonpause = new wxButton(page2panel, cID_BUTTON_PAUSE, wxT("PAUSE"));
mybuttonstop = new wxButton(page2panel, cID_BUTTON_STOP, wxT("STOP"));
/*
wxSizer *sz1 = new wxBoxSizer(wxHORIZONTAL);
sz1->Add(mybuttonplay, 1, wxDEFAULT);
sz1->Add(mybuttonpause, 1, wxDEFAULT);
sz1->Add(mybuttonstop, 1, wxDEFAULT);
wxSizer *sz2 = new wxBoxSizer(wxVERTICAL);
sz2->Add(mpframepanel, 3, wxGROW);
sz2->Add(sz1, 0.2, wxDEFAULT);
this->SetSizer(sz2);
*/
/////////////////////////////////////////// Constructing: Player Embedded
/*
wxBoxSizer *mysizer = new wxBoxSizer(wxVERTICAL);
page2panel->SetSizer(mysizer);
wxTextCtrl *textLog = new wxTextCtrl(page2panel, wxID_ANY, wxT("Under Construction...Orz"), wxPoint(0, 250), wxSize(100, 50), wxTE_MULTILINE);
mysizer->Add(textLog, 1, wxEXPAND | wxALL, 5);
*/
book->AddPage(page2panel, wxT("myRadioTV"));
/////////////////////////////////////////// contents in page 3
// page3panel = new wxPanel(book);
// book->AddPage(page3panel, wxT("myIPTV"));
}
// (end) test frame components
//member functions
void myRadioFrame::ExecuteURL(const wxString &link)
{
// variable declarations
wxArrayString browsers;
wxPathList path_list;
bool BrowserWasFound = false;
unsigned int i = 0;
wxString path;
// Add directories to wxPathList's search path from PATH environment variable
path_list.AddEnvList(wxT("PATH"));
// Add browsers filenames. First item = most priority
browsers.Add(wxT("firefox"));
browsers.Add(wxT("firefox-bin"));
browsers.Add(wxT("mozilla"));
browsers.Add(wxT("mozilla-bin"));
browsers.Add(wxT("opera"));
browsers.Add(wxT("konqueror"));
browsers.Add(wxT("epiphany"));
browsers.Add(wxT("iexplorer"));
for (i = 0; i < browsers.GetCount(); i++)
{
path = path_list.FindAbsoluteValidPath(browsers[i]);
if (path.IsEmpty())
{
continue;
}
else
{
BrowserWasFound = true;
break;
}
}
browsers.Clear();
if (BrowserWasFound)
{
path += wxT(" ");
path += link;
::wxExecute(path);
}
else
{
wxMessageBox(wxT("No browser has been found."));
}
}
// event handlers
void myRadioFrame::OnPageOpen(wxCommandEvent& event)
{
#if wxUSE_FILEDLG
wxString p = wxFileSelector(_("Open HTML document"), wxEmptyString,
wxEmptyString, wxEmptyString, wxT("HTML files|*.htm;*.html"));
if (!p.empty())
myhtmlbrowser->OpenURI(p);
//wxMessageBox(wxWindow::GetHandle());
#endif // wxUSE_FILEDLG
// wxLaunchDefaultBrowser(wxT("www.google.com"));
// ExecuteURL(wxT("www.google.com"));
}
void myRadioFrame::OnAbout(wxCommandEvent& event)
{
wxString msg;
msg.Printf( wxT("Hello and welcome to %s"), wxVERSION_STRING );
wxMessageBox( msg, wxT("Bla bla bla haha...Orz"), wxOK | wxICON_INFORMATION, this );
}
void myRadioFrame::OnQuit(wxCommandEvent& event)
{
Close();
}
void myRadioFrame::OnGoBack(wxCommandEvent& WXUNUSED(event))
{
myhtmlbrowser->GoBack();
}
void myRadioFrame::OnGoForward(wxCommandEvent& WXUNUSED(event))
{
myhtmlbrowser->GoForward();
}
void myRadioFrame::OnGoHome(wxCommandEvent& WXUNUSED(event))
{
myhtmlbrowser->OpenURI(myuri_home);
}
void myRadioFrame::OnUrlTextEntered(wxCommandEvent& event)
{
wxMessageBox("OH NO!");
myhtmlbrowser->OpenURI(event.GetString());
}
void myRadioFrame::OnUrlItemSelected(wxCommandEvent& event)
{
wxMessageBox("OH YA!");
myhtmlbrowser->OpenURI(event.GetString());
}
void myRadioFrame::OnUpdateUI(wxUpdateUIEvent& event)
{
int id = event.GetId();
switch (id)
{
case cID_UNDO:
event.Enable(false); // TODO: undo needs to be implemented
break;
case cID_REDO:
event.Enable(false); // TODO: undo needs to be implemented
break;
case cID_CUT:
event.Enable(myhtmlbrowser->CanCutSelection());
break;
case cID_COPY:
event.Enable(myhtmlbrowser->CanCopySelection());
break;
case cID_COPYLINK:
event.Enable(myhtmlbrowser->CanCopyLinkLocation());
break;
case cID_PASTE:
event.Enable(myhtmlbrowser->CanPaste());
break;
case cID_FINDAGAIN:
//event.Enable(m_find_text.Length() > 0 ? true : false);
break;
case cID_SHOWSOURCE:
case cID_SHOWLINKS:
//event.Enable(m_dom_contentloaded);
break;
}
}
void myRadioFrame::OnButtonPlay(wxCommandEvent& WXUNUSED(event))
{
wxString myplaystr;
// wxFile myexecscript;
// wxProcess *myprocess;
wxFileDialog* myfd;
// myprocess = new wxProcess(mpframepanel);
myplaystr.Clear();
myplaystr.Append("./mplayer -slave -idle -wid");
// myplaystr.Append("mplayer -vo x11 ");
char tryme[20];
sprintf(tryme,"%u", mpframepanel->GetHandle());
myplaystr.Append(" ");
myplaystr.Append(tryme);
myplaystr.Append(" ");
myfd = new wxFileDialog(this);
myplaystr.Append(wxT(myfd->GetFilename()));
myplaystr.Append("./4.rmvb");
// myplaystr.Append("./glass.wmv");
wxMessageBox(wxT(myplaystr));
// ::wxShell(wxT(myplaystr));
::wxExecute(myplaystr);
// ::wxExecute(myplaystr, wxEXEC_SYNC);
// ::wxExecute(myplaystr, wxEXEC_ASYNC, myprocess);
}
void myRadioFrame::OnButtonPause(wxCommandEvent& event)
{
fprintf(stdin,"\npause\n");
}
void myRadioFrame::OnButtonStop(wxCommandEvent& event)
{
}
// (end) event handlers
// destructor
myRadioFrame::~myRadioFrame()
{
myframemanager.UnInit();
}
// event table - myRadioFrame
BEGIN_EVENT_TABLE(myRadioFrame, wxFrame)
// EVT_TEXT_ENTER(cID_URL, myRadioFrame::OnUrlTextEntered)
// EVT_COMBOBOX(cID_URL, myRadioFrame::OnUrlItemSelected)
// menu events
EVT_MENU(mID_FILE_OPEN, myRadioFrame::OnPageOpen)
EVT_MENU(wxID_ABOUT, myRadioFrame::OnAbout)
EVT_MENU(wxID_EXIT, myRadioFrame::OnQuit)
EVT_MENU(cID_BUTTON_BACK, myRadioFrame::OnGoBack)
EVT_MENU(cID_BUTTON_FORWARD, myRadioFrame::OnGoForward)
EVT_MENU(cID_BUTTON_GOHOME, myRadioFrame::OnGoHome)
// EVT_SIZE( myRadioFrame::OnResize)
/*
// update events
EVT_UPDATE_UI(cID_UNDO, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_REDO, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_CUT, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_COPY, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_COPYLINK, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_FINDAGAIN, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_SHOWSOURCE, myRadioFrame::OnUpdateUI)
EVT_UPDATE_UI(cID_SHOWLINKS, myRadioFrame::OnUpdateUI)
*/
// media player button events
EVT_BUTTON(cID_BUTTON_PLAY, myRadioFrame::OnButtonPlay)
EVT_BUTTON(cID_BUTTON_PAUSE, myRadioFrame::OnButtonPause)
EVT_BUTTON(cID_BUTTON_STOP, myRadioFrame::OnButtonStop)
END_EVENT_TABLE()
// (end) event table - myRadioFrame