Skip to content

Commit

Permalink
QtCollider: separate debug stuff out of Common.cpp/h
Browse files Browse the repository at this point in the history
  • Loading branch information
jleben committed May 11, 2011
1 parent 8d7a54c commit 66fb354
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 46 deletions.
1 change: 1 addition & 0 deletions QtCollider/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set( QT_COLLIDER_HDRS
)

set( QT_COLLIDER_SRCS
debug.cpp
interface.cpp
QcApplication.cpp
Common.cpp
Expand Down
18 changes: 0 additions & 18 deletions QtCollider/Common.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
#include "Common.h"

#include <QApplication>
#include <QThread>
#include <QAtomicInt>

static QAtomicInt& debugLevelInt() {
static QAtomicInt *i = new QAtomicInt(0);
return *i;
}

int QtCollider::debugLevel() {
int l = debugLevelInt();
return l;
}

void QtCollider::setDebugLevel( int i ) {
debugLevelInt() = i;
}

void QtCollider::lockLang()
{
qcDebugMsg(2,"locking lang!");
Expand Down
29 changes: 1 addition & 28 deletions QtCollider/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,10 @@
*
************************************************************************/


#ifndef _SC_QT_COMMON_H
#define _SC_QT_COMMON_H

#include <cstdarg>

namespace QtCollider {
int debugLevel();
void setDebugLevel( int );
}

#include <QString>

extern void postfl(const char *fmt, ...);
extern void error(const char *fmt, ...);

#ifdef QC_DEBUG
#define qcDebugMsg( LEVEL, MSG ) \
if( LEVEL <= QtCollider::debugLevel() ) { \
postfl( "Qt:: %s\n", QString(MSG).toStdString().c_str() ); \
}
#else
#define qcDebugMsg( LEVEL, MSG )
#endif

#define qcSCObjectDebugMsg( LEVEL, OBJ, MSG ) \
qcDebugMsg( LEVEL, QString("[%1] %2") \
.arg( OBJ ? slotRawSymbol( &OBJ->classptr->name )->name : "null" ) \
.arg(MSG) )

#define qcErrorMsg( MSG ) error( "Qt: %s\n", QString(MSG).toStdString().c_str() )
#include "debug.h"

#include <QList>
#include <QVariant>
Expand Down
38 changes: 38 additions & 0 deletions QtCollider/debug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/************************************************************************
*
* Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
*
* This file is part of SuperCollider Qt GUI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/

#include "debug.h"

#include <QAtomicInt>

static QAtomicInt& debugLevelInt() {
static QAtomicInt *i = new QAtomicInt(0);
return *i;
}

int QtCollider::debugLevel() {
int l = debugLevelInt();
return l;
}

void QtCollider::setDebugLevel( int i ) {
debugLevelInt() = i;
}
46 changes: 46 additions & 0 deletions QtCollider/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/************************************************************************
*
* Copyright 2010-2011 Jakob Leben (jakob.leben@gmail.com)
*
* This file is part of SuperCollider Qt GUI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
************************************************************************/

namespace QtCollider {
int debugLevel();
void setDebugLevel( int );
}

#include <QString>

extern void postfl(const char *fmt, ...);
extern void error(const char *fmt, ...);

#ifdef QC_DEBUG
#define qcDebugMsg( LEVEL, MSG ) \
if( LEVEL <= QtCollider::debugLevel() ) { \
postfl( "Qt:: %s\n", QString(MSG).toStdString().c_str() ); \
}
#else
#define qcDebugMsg( LEVEL, MSG )
#endif

#define qcSCObjectDebugMsg( LEVEL, OBJ, MSG ) \
qcDebugMsg( LEVEL, QString("[%1] %2") \
.arg( OBJ ? slotRawSymbol( &OBJ->classptr->name )->name : "null" ) \
.arg(MSG) )

#define qcErrorMsg( MSG ) error( "Qt: %s\n", QString(MSG).toStdString().c_str() )

0 comments on commit 66fb354

Please sign in to comment.