Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/qtroot/interface/qrootapplication.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 <iostream.h>
00029 
00030 #include "qrootapplication.h"
00031 #include "TUnixSystem.h"
00032 #include "TApplication.h"
00033 #include "TGX11.h"
00034 #include "lockguard.h"
00035 
00036 extern void qt_ignore_badwindow();
00037 extern bool qt_badwindow();
00038 extern bool qt_xdnd_handle_badwindow();
00039 
00040 static  int qt_x11_errhandler( Display *dpy, XErrorEvent *err ){
00041   // special for modality usage: XGetWindowProperty + XQueryTree()
00042   if ( err->error_code == BadWindow ) {
00043     if ( err->request_code == 25 && qt_xdnd_handle_badwindow() )
00044       return 0;
00045   }
00046   //  special case for  X_SetInputFocus
00047   else if ( err->error_code == BadMatch
00048        && err->request_code == 42  ) {
00049     return 0;
00050   }
00051   // here XError are forwarded
00052   char errstr[256];
00053   XGetErrorText( dpy, err->error_code, errstr, 256 );
00054   qWarning( "X11 Error: %s %d\n  Major opcode:  %d",
00055              errstr, err->error_code, err->request_code );
00056   return 0;
00057 
00058 }
00059 
00060 
00061 bool QRootApplication::fDebug=false;
00062 bool QRootApplication::fWarning=false;
00063 
00064 void qMessageOutput( QtMsgType type, const char *msg )
00065     {
00066         switch ( type ) {
00067             case QtDebugMsg:
00068              if(QRootApplication::fDebug)
00069                 fprintf( stderr, "QtRoot-Debug: \n %s\n", msg );
00070                 break;
00071             case QtWarningMsg:
00072              if(QRootApplication::fWarning)
00073                 fprintf( stderr, "QtRoot-Warning: \n %s\n", msg );
00074                 break;
00075             case QtFatalMsg:
00076                 fprintf( stderr, "QtRoot-Fatal: \n %s\n", msg );
00077                 abort();         // dump core on purpose
00078         }
00079    }
00080 
00081 
00082 QRootApplication::QRootApplication(int argc, char **argv, int poll):QApplication(argc,argv){
00083 
00084   // connect ROOT via Timer call back
00085 
00086 
00087   if (poll == 0){
00088     timer = new QTimer( this );
00089     QObject::connect( timer, SIGNAL(timeout()),
00090             this, SLOT(execute()) );
00091     timer->start( 20, FALSE );
00092 
00093     rtimer = new TTimer(20);
00094     rtimer->Start(20, kFALSE);
00095 
00096   }
00097 
00098 
00099   // install a msg-handler
00100   fWarning=fDebug=false;
00101   qInstallMsgHandler( qMessageOutput );
00102 
00103   // install a filter on the parent
00104 
00105 //   QApplication::installEventFilter( this );
00106 
00107    // install a filter on the parent   // M.Al-Turany
00108 
00109   // use Qt-specific XError Handler (moved this call here from tqapplication JA)
00110    setErrorHandler();
00111 }
00112 
00113 /*
00114 // Custom eventFilter   // M.Al-Turany
00115 bool QRootApplication::eventFilter(QObject *o,QEvent *e){
00116 Qtrootlockguard Global;
00117    //    if(e->type()== QEvent::Paint) {
00118    cout << "QRootApplication::eventFilter" <<endl;
00119    //      return QApplication::eventFilter( o, e );
00120       //  } else {
00121             // standard event processing
00122             return QApplication::eventFilter( o, e );
00123       //}
00124 
00125 }
00126 
00127 */
00128 QRootApplication::~QRootApplication(){
00129   // printf("~QRootApplication \n");
00130 }
00131 
00132 void QRootApplication::execute(){
00133   //call the inner loop of ROOT
00134   gSystem->InnerLoop();
00135 }
00136 
00137 void QRootApplication::setErrorHandler(){
00138   // set a Qt-Specific error Handler
00139  XSetErrorHandler( qt_x11_errhandler );
00140 }
00141 
00142 void QRootApplication::quit(){
00143   // set a Qt-Specific error Handler
00144     cout << " quit ROOT system " << endl;
00145     gSystem->Exit( 0 );
00146 }
00147 
00148 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:09 2005 for Go4-v2.10-5 by doxygen1.2.15