Skip to content
This repository
Browse code

QtCollider: separate debug stuff out of Common.cpp/h

  • Loading branch information...
commit 66fb354343749b2fdba82f0dbb056eb36f555ccd 1 parent 8d7a54c
Jakob Leben jleben authored
1  QtCollider/CMakeLists.txt
@@ -35,6 +35,7 @@ set( QT_COLLIDER_HDRS
35 35 )
36 36
37 37 set( QT_COLLIDER_SRCS
  38 + debug.cpp
38 39 interface.cpp
39 40 QcApplication.cpp
40 41 Common.cpp
18 QtCollider/Common.cpp
... ... @@ -1,23 +1,5 @@
1 1 #include "Common.h"
2 2
3   -#include <QApplication>
4   -#include <QThread>
5   -#include <QAtomicInt>
6   -
7   -static QAtomicInt& debugLevelInt() {
8   - static QAtomicInt *i = new QAtomicInt(0);
9   - return *i;
10   -}
11   -
12   -int QtCollider::debugLevel() {
13   - int l = debugLevelInt();
14   - return l;
15   -}
16   -
17   -void QtCollider::setDebugLevel( int i ) {
18   - debugLevelInt() = i;
19   -}
20   -
21 3 void QtCollider::lockLang()
22 4 {
23 5 qcDebugMsg(2,"locking lang!");
29 QtCollider/Common.h
@@ -19,37 +19,10 @@
19 19 *
20 20 ************************************************************************/
21 21
22   -
23 22 #ifndef _SC_QT_COMMON_H
24 23 #define _SC_QT_COMMON_H
25 24
26   -#include <cstdarg>
27   -
28   -namespace QtCollider {
29   - int debugLevel();
30   - void setDebugLevel( int );
31   -}
32   -
33   -#include <QString>
34   -
35   -extern void postfl(const char *fmt, ...);
36   -extern void error(const char *fmt, ...);
37   -
38   -#ifdef QC_DEBUG
39   - #define qcDebugMsg( LEVEL, MSG ) \
40   - if( LEVEL <= QtCollider::debugLevel() ) { \
41   - postfl( "Qt:: %s\n", QString(MSG).toStdString().c_str() ); \
42   - }
43   -#else
44   - #define qcDebugMsg( LEVEL, MSG )
45   -#endif
46   -
47   -#define qcSCObjectDebugMsg( LEVEL, OBJ, MSG ) \
48   - qcDebugMsg( LEVEL, QString("[%1] %2") \
49   - .arg( OBJ ? slotRawSymbol( &OBJ->classptr->name )->name : "null" ) \
50   - .arg(MSG) )
51   -
52   -#define qcErrorMsg( MSG ) error( "Qt: %s\n", QString(MSG).toStdString().c_str() )
  25 +#include "debug.h"
53 26
54 27 #include <QList>
55 28 #include <QVariant>
38 QtCollider/debug.cpp
... ... @@ -0,0 +1,38 @@
  1 +/************************************************************************
  2 +*
  3 +* Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
  4 +*
  5 +* This file is part of SuperCollider Qt GUI.
  6 +*
  7 +* This program is free software: you can redistribute it and/or modify
  8 +* it under the terms of the GNU General Public License as published by
  9 +* the Free Software Foundation, either version 3 of the License, or
  10 +* (at your option) any later version.
  11 +*
  12 +* This program is distributed in the hope that it will be useful,
  13 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 +* GNU General Public License for more details.
  16 +*
  17 +* You should have received a copy of the GNU General Public License
  18 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  19 +*
  20 +************************************************************************/
  21 +
  22 +#include "debug.h"
  23 +
  24 +#include <QAtomicInt>
  25 +
  26 +static QAtomicInt& debugLevelInt() {
  27 + static QAtomicInt *i = new QAtomicInt(0);
  28 + return *i;
  29 +}
  30 +
  31 +int QtCollider::debugLevel() {
  32 + int l = debugLevelInt();
  33 + return l;
  34 +}
  35 +
  36 +void QtCollider::setDebugLevel( int i ) {
  37 + debugLevelInt() = i;
  38 +}
46 QtCollider/debug.h
... ... @@ -0,0 +1,46 @@
  1 +/************************************************************************
  2 +*
  3 +* Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
  4 +*
  5 +* This file is part of SuperCollider Qt GUI.
  6 +*
  7 +* This program is free software: you can redistribute it and/or modify
  8 +* it under the terms of the GNU General Public License as published by
  9 +* the Free Software Foundation, either version 3 of the License, or
  10 +* (at your option) any later version.
  11 +*
  12 +* This program is distributed in the hope that it will be useful,
  13 +* but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 +* GNU General Public License for more details.
  16 +*
  17 +* You should have received a copy of the GNU General Public License
  18 +* along with this program. If not, see <http://www.gnu.org/licenses/>.
  19 +*
  20 +************************************************************************/
  21 +
  22 +namespace QtCollider {
  23 + int debugLevel();
  24 + void setDebugLevel( int );
  25 +}
  26 +
  27 +#include <QString>
  28 +
  29 +extern void postfl(const char *fmt, ...);
  30 +extern void error(const char *fmt, ...);
  31 +
  32 +#ifdef QC_DEBUG
  33 + #define qcDebugMsg( LEVEL, MSG ) \
  34 + if( LEVEL <= QtCollider::debugLevel() ) { \
  35 + postfl( "Qt:: %s\n", QString(MSG).toStdString().c_str() ); \
  36 + }
  37 +#else
  38 + #define qcDebugMsg( LEVEL, MSG )
  39 +#endif
  40 +
  41 +#define qcSCObjectDebugMsg( LEVEL, OBJ, MSG ) \
  42 + qcDebugMsg( LEVEL, QString("[%1] %2") \
  43 + .arg( OBJ ? slotRawSymbol( &OBJ->classptr->name )->name : "null" ) \
  44 + .arg(MSG) )
  45 +
  46 +#define qcErrorMsg( MSG ) error( "Qt: %s\n", QString(MSG).toStdString().c_str() )

0 comments on commit 66fb354

Please sign in to comment.
Something went wrong with that request. Please try again.