Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

qrootapplication.cpp

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 //Author : Denis Bertini 01.11.2000
00017 
00018 /**************************************************************************
00019 * Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI           *
00020 *                     Planckstr. 1, 64291 Darmstadt, Germany              *
00021 *                     All rights reserved.                                *
00022 * Contact:            http://go4.gsi.de                                   *
00023 *                                                                         *
00024 * This software can be used under the license agreements as stated in     *
00025 * Go4License.txt file which is part of the distribution.                  *
00026 ***************************************************************************/
00027 
00028 #include "qrootapplication.h"
00029 
00030 #include "Riostream.h"
00031 #include <stdlib.h>
00032 #include "TTimer.h"
00033 #include "TSystem.h"
00034 #include "TGX11.h"
00035 
00036 #include "qobject.h"
00037 #include "qtimer.h"
00038 
00039 #include "lockguard.h"
00040 
00041 extern void qt_ignore_badwindow();
00042 extern bool qt_badwindow();
00043 extern bool qt_xdnd_handle_badwindow();
00044 
00045 static  int qt_x11_errhandler( Display *dpy, XErrorEvent *err ){
00046   // special for modality usage: XGetWindowProperty + XQueryTree()
00047   if ( err->error_code == BadWindow ) {
00048     if ( err->request_code == 25 && qt_xdnd_handle_badwindow() )
00049       return 0;
00050   }
00051   //  special case for  X_SetInputFocus
00052   else if ( err->error_code == BadMatch
00053        && err->request_code == 42  ) {
00054     return 0;
00055   }
00056   // here XError are forwarded
00057   char errstr[256];
00058   XGetErrorText( dpy, err->error_code, errstr, 256 );
00059   qWarning( "X11 Error: %s %d\n  Major opcode:  %d",
00060              errstr, err->error_code, err->request_code );
00061   return 0;
00062 
00063 }
00064 
00065 
00066 bool QRootApplication::fDebug=false;
00067 bool QRootApplication::fWarning=false;
00068 
00069 void qMessageOutput( QtMsgType type, const char *msg )
00070     {
00071         switch ( type ) {
00072             case QtDebugMsg:
00073              if(QRootApplication::fDebug)
00074                 fprintf( stderr, "QtRoot-Debug: \n %s\n", msg );
00075                 break;
00076             case QtWarningMsg:
00077              if(QRootApplication::fWarning)
00078                 fprintf( stderr, "QtRoot-Warning: \n %s\n", msg );
00079                 break;
00080             case QtFatalMsg:
00081                 fprintf( stderr, "QtRoot-Fatal: \n %s\n", msg );
00082                 abort();         // dump core on purpose
00083         }
00084    }
00085 
00086 
00087 QRootApplication::QRootApplication(int& argc, char **argv, int poll) :
00088    QApplication(argc,argv, true)
00089 {
00090 
00091   // connect ROOT via Timer call back
00092 
00093 
00094   if (poll == 0){
00095     timer = new QTimer( this );
00096     QObject::connect( timer, SIGNAL(timeout()),
00097             this, SLOT(execute()) );
00098     timer->start( 20, FALSE );
00099 
00100     rtimer = new TTimer(20);
00101     rtimer->Start(20, kFALSE);
00102 
00103   }
00104 
00105 
00106   // install a msg-handler
00107   fWarning=fDebug=false;
00108   qInstallMsgHandler( qMessageOutput );
00109 
00110   // install a filter on the parent
00111 
00112 //   QApplication::installEventFilter( this );
00113 
00114    // install a filter on the parent   // M.Al-Turany
00115 
00116   // use Qt-specific XError Handler (moved this call here from tqapplication JA)
00117    setErrorHandler();
00118 }
00119 
00120 /*
00121 // Custom eventFilter   // M.Al-Turany
00122 bool QRootApplication::eventFilter(QObject *o,QEvent *e){
00123 Qtrootlockguard Global;
00124    //    if(e->type()== QEvent::Paint) {
00125    cout << "QRootApplication::eventFilter" <<endl;
00126    //      return QApplication::eventFilter( o, e );
00127       //  } else {
00128             // standard event processing
00129             return QApplication::eventFilter( o, e );
00130       //}
00131 
00132 }
00133 
00134 */
00135 QRootApplication::~QRootApplication()
00136 {
00137 }
00138 
00139 void QRootApplication::execute()
00140 //call the inner loop of ROOT
00141 {
00142    gSystem->InnerLoop();
00143 }
00144 
00145 void QRootApplication::setErrorHandler()
00146 // set a Qt-Specific error Handler
00147 {
00148    XSetErrorHandler( qt_x11_errhandler );
00149 }
00150 
00151 void QRootApplication::quit()
00152 {
00153    gSystem->Exit( 0 );
00154 }
00155 
00156 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:33 2008 for Go4-v3.04-1 by  doxygen 1.4.2