summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2011-08-15 09:51:23 +0000
committerBenny Prijono <bennylp@teluu.com>2011-08-15 09:51:23 +0000
commitccde039efe801c17b8f4b91859a945525d02ecc0 (patch)
tree5791b0dcb386ad4fd4995afc9079eb271ce7dd6e
parent2ba74a19fcdad405b6971509f69aab8843c3abb7 (diff)
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
-rw-r--r--pjsip-apps/src/vidgui/vidgui.cpp26
1 files changed, 23 insertions, 3 deletions
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 <SDL.h>
#include <assert.h>
#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();
}