GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
QRootApplication.cpp
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14//Author : Denis Bertini 01.11.2000
15
16/**************************************************************************
17* Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI *
18* Planckstr. 1, 64291 Darmstadt, Germany *
19* All rights reserved. *
20* Contact: http://go4.gsi.de *
21* *
22* This software can be used under the license agreements as stated in *
23* Go4License.txt file which is part of the distribution. *
24***************************************************************************/
25
26#include "QRootApplication.h"
27
28#include <iostream>
29
30#include "TSystem.h"
31
32#include <QtCore/QTimer>
33
34#ifndef _MSC_VER
35#ifdef __GO4X11__
36
37#include <X11/Xlib.h>
38
39static int qt_x11_errhandler( Display *dpy, XErrorEvent *err )
40{
41
42 // special for modality usage: XGetWindowProperty + XQueryTree()
43 if ( err->error_code == BadWindow ) {
44 //if ( err->request_code == 25 && qt_xdnd_handle_badwindow() )
45 return 0;
46 }
47 // special case for X_SetInputFocus
48 else if ( err->error_code == BadMatch
49 && err->request_code == 42 ) {
50 return 0;
51 }
52 else if ( err->error_code == BadDrawable
53 && err->request_code == 14 ) {
54 return 0;
55 }
56
57 // here XError are forwarded
58 char errstr[256];
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 );
62 return 0;
63}
64
65#endif
66#endif
67
68bool QRootApplication::fDebug = false; //false;
69bool QRootApplication::fWarning = false; //false;
71
72void q5MessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
73{
74 QByteArray localMsg = msg.toLocal8Bit();
75 switch (type) {
76 case QtDebugMsg:
78 fprintf(stderr, "QtRoot-Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
79 break;
80 case QtWarningMsg:
82 fprintf(stderr, "QtRoot-Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
83 break;
84 case QtCriticalMsg:
85 fprintf(stderr, "QtRoot-Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
86 break;
87 case QtFatalMsg:
88 fprintf(stderr, "QtRoot-Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
89 abort();
90 default:
91 fprintf(stderr, "QtRoot-other: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
92 break;
93 }
94}
95
96QRootApplication::QRootApplication(int& argc, char **argv, int poll) :
97 QApplication(argc,argv, true)
98{
99
100 // connect ROOT via Timer call back
101 if (poll == 0){
102 timer = new QTimer( this );
103 QObject::connect( timer, &QTimer::timeout, this, &QRootApplication::execute);
104 timer->setSingleShot(false);
105 timer->start(20);
106 }
107 // install a msg-handler
108 qInstallMessageHandler( q5MessageOutput );
109
110 // install a filter on the parent
111 // use Qt-specific XError Handler (moved this call here from tqapplication JA)
112 // QApplication::installEventFilter( this );
113
114 const char *env = gSystem->Getenv("ROOT_CANVAS");
115 int flag = 0;
116 if (env) {
117 if ((strcmp(env, "yes") == 0) || (strcmp(env, "YES") == 0))
118 flag = 1;
119 else if ((strcmp(env, "no") == 0) || (strcmp(env, "NO") == 0))
120 flag = -1;
121 }
122
123#ifdef _MSC_VER
124 // under Windows one should explicit enable these methods
125 fRootCanvasMenusEnabled = (flag == 1);
126#else
127#ifdef __GO4X11__
128 XSetErrorHandler( qt_x11_errhandler );
129#endif
130 // under Unix one should explicit disable these methods
131 fRootCanvasMenusEnabled = (flag != -1);
132#endif
133}
134
138
140{
141 //call the inner loop of ROOT
142
143 // gSystem->InnerLoop();
144
145 // SL 28.5.2015: use ProcessEvents instead of InnerLoop to avoid total block of the qt event loop
146 gSystem->ProcessEvents();
147}
148
150{
151 // gSystem->Exit( 0 );
152}
153
void q5MessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
static bool IsRootCanvasMenuEnabled()
QRootApplication(int &argc, char **argv, int poll=0)
static bool fRootCanvasMenusEnabled
Variable defines if menu methods, which creating new canvas, are enabled.