From ccde039efe801c17b8f4b91859a945525d02ecc0 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Mon, 15 Aug 2011 09:51:23 +0000 Subject: Re #1327 (vidgui): fixed crash on Linux because SDL_Init() needs to be called prior to creating QApplication git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3695 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/vidgui/vidgui.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pjsip-apps') diff --git a/pjsip-apps/src/vidgui/vidgui.cpp b/pjsip-apps/src/vidgui/vidgui.cpp index ce1c89b1..d127dbdb 100644 --- a/pjsip-apps/src/vidgui/vidgui.cpp +++ b/pjsip-apps/src/vidgui/vidgui.cpp @@ -19,6 +19,7 @@ #include "vidgui.h" #include "vidwin.h" +#include #include #define LOG_FILE "vidgui.log" @@ -574,7 +575,24 @@ static pjsip_module mod_default_handler = int main(int argc, char *argv[]) { + /* At least on Linux, we have to initialize SDL video subsystem prior to + * creating/initializing QApplication, otherwise we'll segfault miserably + * in SDL_CreateWindow(). Here's a stack trace if you're interested: + + Thread [7] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation fault.) + 13 XCreateIC() + 12 SetupWindowData() + 11 X11_CreateWindow() + 10 SDL_CreateWindow() + .. + */ + if ( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) { + printf("Unable to init SDL: %s\n", SDL_GetError()); + return 1; + } + QApplication app(argc, argv); + MainWin win; win.show(); @@ -583,9 +601,11 @@ int main(int argc, char *argv[]) return 1; } - /* Initialize our module to handle otherwise unhandled request */ - pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), - &mod_default_handler); + /* We want to be registrar too! */ + if (pjsua_get_pjsip_endpt()) { + pjsip_endpt_register_module(pjsua_get_pjsip_endpt(), + &mod_default_handler); + } return app.exec(); } -- cgit v1.2.3