Skip to content

Commit

Permalink
ENH: Use QT_NO_DEBUG instead of USE_TRACE
Browse files Browse the repository at this point in the history
  • Loading branch information
Punzo committed Jan 22, 2024
1 parent ac5febb commit 3687e3f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 32 deletions.
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,6 @@ if(BUILD_TESTING)
")
endif()

#-----------------------------------------------------------------------------
# EnableTrace
#
option(CTK_ENABLE_TRACE "Enable/Disable trace logging" OFF)
mark_as_advanced(CTK_ENABLE_TRACE)
mark_as_superbuild(CTK_ENABLE_TRACE)

if (CTK_ENABLE_TRACE)
MESSAGE(STATUS "CTK_ENABLE_TRACE")
add_definitions(-DUSE_TRACE)
endif()

#-----------------------------------------------------------------------------
# QtTesting
#
Expand Down
40 changes: 20 additions & 20 deletions Libs/DICOM/Core/ctkDICOMDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool ctkDICOMDatabasePrivate::loggedExec(QSqlQuery& query, const QString& queryS
success = query.exec();
}

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
if (!success)
{
QSqlError sqlError = query.lastError();
Expand All @@ -182,7 +182,7 @@ bool ctkDICOMDatabasePrivate::loggedExecBatch(QSqlQuery& query)
bool success;
success = query.execBatch();

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
if (!success)
{
QSqlError sqlError = query.lastError();
Expand Down Expand Up @@ -288,7 +288,7 @@ bool ctkDICOMDatabasePrivate::executeScript(const QString script)
{
if (! (*it).startsWith("--") )
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace(*it + "\n");
#endif
query.exec(*it);
Expand Down Expand Up @@ -342,7 +342,7 @@ bool ctkDICOMDatabasePrivate::insertPatient(const ctkDICOMItem& dataset, int& db
// we found him
dbPatientID = checkPatientExistsQuery.value(checkPatientExistsQuery.record().indexOf("UID")).toInt();

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Found patient in the database as UId: " + QString::number(dbPatientID));
foreach(QString key, this->InsertedPatientsCompositeIDCache.keys())
{
Expand Down Expand Up @@ -381,7 +381,7 @@ bool ctkDICOMDatabasePrivate::insertPatient(const ctkDICOMItem& dataset, int& db
dbPatientID = insertPatientStatement.lastInsertId().toInt();
this->InsertedPatientsCompositeIDCache[compositeID] = dbPatientID;

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("New patient inserted: database item ID = " + QString().setNum(dbPatientID));
#endif
return true;
Expand All @@ -398,7 +398,7 @@ bool ctkDICOMDatabasePrivate::insertStudy(const ctkDICOMItem& dataset, int dbPat
checkStudyExistsQuery.exec();
if (!checkStudyExistsQuery.next())
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Need to insert new study: " + studyInstanceUID);
#endif

Expand Down Expand Up @@ -442,7 +442,7 @@ bool ctkDICOMDatabasePrivate::insertStudy(const ctkDICOMItem& dataset, int dbPat
}
else
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Used existing study: " + studyInstanceUID);
#endif
this->InsertedStudyUIDsCache.insert(studyInstanceUID);
Expand All @@ -457,13 +457,13 @@ bool ctkDICOMDatabasePrivate::insertSeries(const ctkDICOMItem& dataset, QString
QSqlQuery checkSeriesExistsQuery(this->Database);
checkSeriesExistsQuery.prepare( "SELECT * FROM Series WHERE SeriesInstanceUID = ?" );
checkSeriesExistsQuery.bindValue( 0, seriesInstanceUID );
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Statement: " + checkSeriesExistsQuery.lastQuery() );
#endif
checkSeriesExistsQuery.exec();
if (!checkSeriesExistsQuery.next())
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Need to insert new series: " + seriesInstanceUID);
#endif
QString seriesDate(dataset.GetElementAsString(DCM_SeriesDate) );
Expand Down Expand Up @@ -514,7 +514,7 @@ bool ctkDICOMDatabasePrivate::insertSeries(const ctkDICOMItem& dataset, QString
}
else
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Used existing series: " + seriesInstanceUID);
#endif
this->InsertedSeriesUIDsCache.insert(seriesInstanceUID);
Expand Down Expand Up @@ -859,7 +859,7 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, const QString&
QString sopInstanceUID(dataset.GetElementAsString(DCM_SOPInstanceUID));

// Check to see if the file has already been loaded
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("inserting filePath: " + filePath);
#endif

Expand All @@ -878,15 +878,15 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, const QString&
{
if (datasetUpToDate)
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("File " + databaseFilename + " already added");
#endif
return;
}
// File is updated, delete record and re-index
if (!this->removeImage(sopInstanceUID))
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("File " + filePath + " cannot be added, failed to update existing values in the database");
#endif
return;
Expand Down Expand Up @@ -915,7 +915,7 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, const QString&
bool databaseWasChanged = this->insertPatientStudySeries(dataset, patientID, patientsName);
if (!sopInstanceUID.isEmpty() && !seriesInstanceUID.isEmpty() && !storedFilePath.isEmpty())
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Maybe add Instance");
#endif
bool alreadyInserted = false;
Expand Down Expand Up @@ -966,7 +966,7 @@ void ctkDICOMDatabasePrivate::insert(const ctkDICOMItem& dataset, const QString&
// let users of this class track when things happen
emit q->instanceAdded(sopInstanceUID);

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace("Instance Added");
#endif
databaseWasChanged = true;
Expand Down Expand Up @@ -2408,13 +2408,13 @@ void ctkDICOMDatabase::insert( const QString& filePath, bool storeFile, bool gen
/// first we check if the file is already in the database
if (fileExistsAndUpToDate(filePath))
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace( "File " + filePath + " already added.");
#endif
return;
}

#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace( "Processing " + filePath );
#endif

Expand Down Expand Up @@ -2556,7 +2556,7 @@ void ctkDICOMDatabase::insert(const QList<ctkDICOMDatabase::IndexingResult>& ind
insertImageStatement.addBindValue(QDateTime::currentDateTime());
insertImageStatement.exec();
emit instanceAdded(sopInstanceUID);
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace( "Instance Added" );
#endif
databaseWasChanged = true;
Expand Down Expand Up @@ -2778,7 +2778,7 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR
(!storedFilePath.isEmpty() ||
!url.isEmpty()))
{
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace( "Maybe add Instance" );
#endif
bool alreadyInserted = false;
Expand Down Expand Up @@ -2828,7 +2828,7 @@ void ctkDICOMDatabase::insert(QList<QSharedPointer<ctkDICOMJobResponseSet>> jobR

// let users of this class track when things happen
emit instanceAdded(sopInstanceUID);
#ifdef USE_TRACE
#ifndef QT_NO_DEBUG
logger.trace( "Instance Added" );
#endif
databaseWasChanged = true;
Expand Down

0 comments on commit 3687e3f

Please sign in to comment.