32 #include <QtCore/QTimer>
39 static int qt_x11_errhandler( Display *dpy, XErrorEvent *err )
43 if ( err->error_code == BadWindow ) {
48 else if ( err->error_code == BadMatch
49 && err->request_code == 42 ) {
52 else if ( err->error_code == BadDrawable
53 && err->request_code == 14 ) {
59 XGetErrorText( dpy, err->error_code, errstr, 256 );
60 qWarning(
"X11 Error: %s %d\n Major opcode: %d",
61 errstr, err->error_code, err->request_code );
72 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
73 void qMessageOutput( QtMsgType type,
const char *
msg )
77 if(QRootApplication::fDebug)
78 std::cerr <<
"QtRoot-Debug: " << msg << std::endl;
81 if(QRootApplication::fWarning)
82 std::cerr <<
"QtRoot-Warning: " << msg << std::endl;
85 std::cerr <<
"QtRoot-Fatal: " << msg << std::endl;
88 std::cerr <<
"QtRoot-Critical: " << msg << std::endl;
91 std::cerr <<
"QtRoot-Other: " << msg << std::endl;
97 void q5MessageOutput(QtMsgType type,
const QMessageLogContext &context,
const QString &msg)
99 QByteArray localMsg = msg.toLocal8Bit();
102 if(QRootApplication::fDebug)
103 fprintf(stderr,
"QtRoot-Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
106 if(QRootApplication::fWarning)
107 fprintf(stderr,
"QtRoot-Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
110 fprintf(stderr,
"QtRoot-Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
113 fprintf(stderr,
"QtRoot-Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
116 fprintf(stderr,
"QtRoot-other: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
123 QApplication(argc,argv, true)
128 timer =
new QTimer(
this );
129 QObject::connect(
timer, SIGNAL(timeout()),
131 timer->setSingleShot(
false);
136 #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
137 qInstallMsgHandler( qMessageOutput );
146 const char* env = gSystem->Getenv(
"ROOT_CANVAS");
149 if ((strcmp(env,
"yes")==0) || (strcmp(env,
"YES")==0)) flag = 1;
else
150 if ((strcmp(env,
"no")==0) || (strcmp(env,
"NO")==0)) flag = -1;
158 XSetErrorHandler( qt_x11_errhandler );
176 gSystem->ProcessEvents();
virtual ~QRootApplication()
QRootApplication(int &argc, char **argv, int poll=0)
static bool IsRootCanvasMenuEnabled()
void q5MessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
static bool fRootCanvasMenusEnabled