summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRJ Ryan <rryan@mixxx.org>2014-12-17 23:50:07 -0500
committerRJ Ryan <rryan@mixxx.org>2014-12-17 23:55:36 -0500
commitd15a2b97cbabd689a1b43c17c2328749b117fbc9 (patch)
tree05d40ba0c7daf7c2f7555fe9a68f0eb53d596a51
parent1eaca501c86ea7004f382107c485e2014cfadae3 (diff)
Convert most Q_ASSERTs into DEBUG_ASSERT_AND_HANDLEs.
Handle errors gracefully in release builds.
-rw-r--r--plugins/soundsourcem4a/m4a/mp4-mixxx.cpp6
-rw-r--r--plugins/soundsourcem4a/soundsourcem4a.cpp7
-rw-r--r--src/control/controlvalue.h3
-rw-r--r--src/dlganalysis.cpp12
-rw-r--r--src/dlgautodj.cpp11
-rw-r--r--src/dlghidden.cpp11
-rw-r--r--src/dlgmissing.cpp11
-rw-r--r--src/dlgrecording.cpp11
-rw-r--r--src/effects/effectparameter.cpp38
-rw-r--r--src/effects/effectsmanager.cpp5
-rw-r--r--src/engine/enginebuffer.cpp9
-rw-r--r--src/engine/enginebufferscalelinear.cpp2
-rw-r--r--src/engine/enginedelay.cpp9
-rw-r--r--src/engine/enginefilterdelay.h29
-rw-r--r--src/engine/sync/enginesync.cpp5
-rw-r--r--src/engine/sync/synccontrol.cpp3
-rw-r--r--src/errordialoghandler.cpp5
-rw-r--r--src/library/baseplaylistfeature.cpp5
-rw-r--r--src/library/basesqltablemodel.cpp6
-rw-r--r--src/library/dao/cue.cpp9
-rw-r--r--src/library/dao/cuedao.cpp5
-rw-r--r--src/library/dao/trackdao.cpp33
-rw-r--r--src/library/library.cpp9
-rw-r--r--src/library/proxytrackmodel.cpp45
-rw-r--r--src/library/schemamanager.cpp16
-rw-r--r--src/library/sidebarmodel.cpp5
-rw-r--r--src/library/trackcollection.cpp9
-rw-r--r--src/playermanager.cpp15
-rw-r--r--src/samplerbank.cpp9
-rw-r--r--src/sampleutil.h2
-rw-r--r--src/soundmanagerconfig.cpp8
-rw-r--r--src/widget/controlwidgetconnection.cpp13
-rw-r--r--src/widget/wtracktableview.cpp13
-rw-r--r--src/widget/wwidget.cpp3
34 files changed, 269 insertions, 113 deletions
diff --git a/plugins/soundsourcem4a/m4a/mp4-mixxx.cpp b/plugins/soundsourcem4a/m4a/mp4-mixxx.cpp
index d6503f7239..0ab967af34 100644
--- a/plugins/soundsourcem4a/m4a/mp4-mixxx.cpp
+++ b/plugins/soundsourcem4a/m4a/mp4-mixxx.cpp
@@ -10,6 +10,7 @@
#include <stdlib.h>
#include "util/math.h"
+#include "util/assert.h"
/*
* Copyright 2006 dnk <dnk@bjum.net>
@@ -407,7 +408,10 @@ static int mp4_seek_sample(struct input_plugin_data *ip_data, int sample)
struct mp4_private *priv;
priv = (mp4_private*) ip_data->private_ipd;
- Q_ASSERT(sample >= 0);
+ // Ignore the seek if the sample is invalid.
+ DEBUG_ASSERT_AND_HANDLE(sample >= 0) {
+ return mp4_current_sample(ip_data);
+ }
// The first frame is samples 0 through 2047. The first sample of the second
// frame is 2048. 2048 / 2048 = 1, so frame_for_sample will be 2 on the
// 2048'th sample. The frame_offset_samples is how many samples into the frame
diff --git a/plugins/soundsourcem4a/soundsourcem4a.cpp b/plugins/soundsourcem4a/soundsourcem4a.cpp
index c8399d7555..8932bacfef 100644
--- a/plugins/soundsourcem4a/soundsourcem4a.cpp
+++ b/plugins/soundsourcem4a/soundsourcem4a.cpp
@@ -17,6 +17,7 @@
#include "soundsourcem4a.h"
#include "soundsourcetaglib.h"
#include "sampleutil.h"
+#include "util/assert.h"
#include <taglib/mp4file.h>
#include <neaacdec.h>
@@ -91,7 +92,11 @@ int SoundSourceM4A::initializeDecoder()
// mp4_open succeeded -> populate variables
mp4_private* mp = (struct mp4_private*)ipd.private_ipd;
- Q_ASSERT(mp);
+ DEBUG_ASSERT_AND_HANDLE(mp) {
+ mp4_close(&ipd);
+ return ERR;
+ }
+
mp4file = mp->mp4.handle;
filelength = mp4_total_samples(&ipd);
setSampleRate(mp->sample_rate);
diff --git a/src/control/controlvalue.h b/src/control/controlvalue.h
index de12e9a387..7b8a6efd18 100644
--- a/src/control/controlvalue.h
+++ b/src/control/controlvalue.h
@@ -7,6 +7,7 @@
#include <QObject>
#include "util/compatibility.h"
+#include "util/assert.h"
// for look free access, this value has to be >= the number of value using threads
// value must be a fraction of an integer
@@ -104,7 +105,7 @@ class ControlValueAtomicBase {
m_writeIndex(1) {
// NOTE(rryan): Wrapping max with parentheses avoids conflict with the
// max macro defined in windows.h.
- Q_ASSERT(((std::numeric_limits<unsigned int>::max)() % cRingSize) == (cRingSize - 1));
+ DEBUG_ASSERT(((std::numeric_limits<unsigned int>::max)() % cRingSize) == (cRingSize - 1));
}
private:
diff --git a/src/dlganalysis.cpp b/src/dlganalysis.cpp
index e6746d8f73..b2d9c8b641 100644
--- a/src/dlganalysis.cpp
+++ b/src/dlganalysis.cpp
@@ -6,7 +6,7 @@
#include "widget/wanalysislibrarytableview.h"
#include "library/trackcollection.h"
#include "dlganalysis.h"
-
+#include "util/assert.h"
DlgAnalysis::DlgAnalysis(QWidget* parent,
ConfigObject<ConfigValue>* pConfig,
@@ -31,10 +31,12 @@ DlgAnalysis::DlgAnalysis(QWidget* parent,
this, SIGNAL(trackSelected(TrackPointer)));
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
- Q_ASSERT(box); // Assumes the form layout is a QVBox/QHBoxLayout!
- box->removeWidget(m_pTrackTablePlaceholder);
- m_pTrackTablePlaceholder->hide();
- box->insertWidget(1, m_pAnalysisLibraryTableView);
+ DEBUG_ASSERT_AND_HANDLE(box) { // Assumes the form layout is a QVBox/QHBoxLayout!
+ } else {
+ box->removeWidget(m_pTrackTablePlaceholder);
+ m_pTrackTablePlaceholder->hide();
+ box->insertWidget(1, m_pAnalysisLibraryTableView);
+ }
m_pAnalysisLibraryTableModel = new AnalysisLibraryTableModel(this, pTrackCollection);
m_pAnalysisLibraryTableView->loadTrackModel(m_pAnalysisLibraryTableModel);
diff --git a/src/dlgautodj.cpp b/src/dlgautodj.cpp
index 3eac250f45..55722f84f1 100644
--- a/src/dlgautodj.cpp
+++ b/src/dlgautodj.cpp
@@ -4,6 +4,7 @@
#include "library/playlisttablemodel.h"
#include "widget/wtracktableview.h"
+#include "util/assert.h"
DlgAutoDJ::DlgAutoDJ(QWidget* parent,
ConfigObject<ConfigValue>* pConfig,
@@ -28,10 +29,12 @@ DlgAutoDJ::DlgAutoDJ(QWidget* parent,
this, SIGNAL(trackSelected(TrackPointer)));
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
- Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
- box->removeWidget(m_pTrackTablePlaceholder);
- m_pTrackTablePlaceholder->hide();
- box->insertWidget(1, m_pTrackTableView);
+ DEBUG_ASSERT_AND_HANDLE(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
+ } else {
+ box->removeWidget(m_pTrackTablePlaceholder);
+ m_pTrackTablePlaceholder->hide();
+ box->insertWidget(1, m_pTrackTableView);
+ }
// We do _NOT_ take ownership of this from AutoDJProcessor.
m_pAutoDJTableModel = m_pAutoDJProcessor->getTableModel();
diff --git a/src/dlghidden.cpp b/src/dlghidden.cpp
index ffc37a27f8..a80690a1a3 100644
--- a/src/dlghidden.cpp
+++ b/src/dlghidden.cpp
@@ -3,6 +3,7 @@
#include "dlghidden.h"
#include "library/hiddentablemodel.h"
#include "widget/wtracktableview.h"
+#include "util/assert.h"
DlgHidden::DlgHidden(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection, MixxxKeyboard* pKeyboard)
@@ -15,10 +16,12 @@ DlgHidden::DlgHidden(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
// Install our own trackTable
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
- Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
- box->removeWidget(m_pTrackTablePlaceholder);
- m_pTrackTablePlaceholder->hide();
- box->insertWidget(1, m_pTrackTableView);
+ DEBUG_ASSERT_AND_HANDLE(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
+ } else {
+ box->removeWidget(m_pTrackTablePlaceholder);
+ m_pTrackTablePlaceholder->hide();
+ box->insertWidget(1, m_pTrackTableView);
+ }
m_pHiddenTableModel = new HiddenTableModel(this, pTrackCollection);
m_pTrackTableView->loadTrackModel(m_pHiddenTableModel);
diff --git a/src/dlgmissing.cpp b/src/dlgmissing.cpp
index 55fef44a25..85b48479a4 100644
--- a/src/dlgmissing.cpp
+++ b/src/dlgmissing.cpp
@@ -2,6 +2,7 @@
#include "library/missingtablemodel.h"
#include "widget/wtracktableview.h"
+#include "util/assert.h"
DlgMissing::DlgMissing(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection, MixxxKeyboard* pKeyboard)
@@ -14,10 +15,12 @@ DlgMissing::DlgMissing(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
// Install our own trackTable
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
- Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
- box->removeWidget(m_pTrackTablePlaceholder);
- m_pTrackTablePlaceholder->hide();
- box->insertWidget(1, m_pTrackTableView);
+ DEBUG_ASSERT_AND_HANDLE(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
+ } else {
+ box->removeWidget(m_pTrackTablePlaceholder);
+ m_pTrackTablePlaceholder->hide();
+ box->insertWidget(1, m_pTrackTableView);
+ }
m_pMissingTableModel = new MissingTableModel(this, pTrackCollection);
m_pTrackTableView->loadTrackModel(m_pMissingTableModel);
diff --git a/src/dlgrecording.cpp b/src/dlgrecording.cpp
index 5a27a0d563..6695e88547 100644
--- a/src/dlgrecording.cpp
+++ b/src/dlgrecording.cpp
@@ -6,6 +6,7 @@
#include "widget/wwidget.h"
#include "widget/wskincolor.h"
#include "widget/wtracktableview.h"
+#include "util/assert.h"
DlgRecording::DlgRecording(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
TrackCollection* pTrackCollection,
@@ -35,10 +36,12 @@ DlgRecording::DlgRecording(QWidget* parent, ConfigObject<ConfigValue>* pConfig,
this, SLOT(slotDurationRecorded(QString)));
QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout());
- Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout!
- box->removeWidget(m_pTrackTablePlaceholder);
- m_pTrackTablePlaceholder->hide();
- box->insertWidget(1, m_pTrackTableView);
+ DEBUG_ASSERT_AND_HANDLE(box) { //Assumes the form layout is a QVBox/QHBoxLayout!
+ } else {
+ box->removeWidget(m_pTrackTablePlaceholder);
+ m_pTrackTablePlaceholder->hide();
+ box->insertWidget(1, m_pTrackTableView);
+ }
m_recordingDir = m_pRecordingManager->getRecordingDir();
diff --git a/src/effects/effectparameter.cpp b/src/effects/effectparameter.cpp
index 7ce968d1bd..7092fa9ef8 100644
--- a/src/effects/effectparameter.cpp
+++ b/src/effects/effectparameter.cpp
@@ -3,6 +3,7 @@
#include "effects/effectparameter.h"
#include "effects/effectsmanager.h"
#include "effects/effect.h"
+#include "util/assert.h"
EffectParameter::EffectParameter(Effect* pEffect, EffectsManager* pEffectsManager,
int iParameterNumber, const EffectManifestParameter& parameter)
@@ -130,8 +131,16 @@ double EffectParameter::getMinimum() const {
}
void EffectParameter::setMinimum(double minimum) {
- m_minimum = minimum;
+ // There's a degenerate case here where the maximum could be lower
+ // than the manifest minimum. If that's the case, then the minimum
+ // value is currently below the manifest minimum. Since similar
+ // guards exist in the setMaximum call, this should not be able to
+ // happen.
+ DEBUG_ASSERT_AND_HANDLE(m_minimum >= m_parameter.getMinimum()) {
+ return;
+ }
+ m_minimum = minimum;
if (m_minimum < m_parameter.getMinimum()) {
qWarning() << debugString() << "WARNING: Minimum value is less than plugin's absolute minimum, clamping.";
m_minimum = m_parameter.getMinimum();
@@ -142,17 +151,14 @@ void EffectParameter::setMinimum(double minimum) {
m_minimum = m_maximum;
}
- // There's a degenerate case here where the maximum could be lower
- // than the manifest minimum. If that's the case, then the minimum
- // value is currently below the manifest minimum. Since similar
- // guards exist in the setMaximum call, this should not be able to
- // happen.
- Q_ASSERT(m_minimum >= m_parameter.getMinimum());
-
if (clampValue()) {
qWarning() << debugString() << "WARNING: Value was outside of new minimum, clamped.";
}
+ if (clampDefault()) {
+ qWarning() << debugString() << "WARNING: Default was outside of new minimum, clamped.";
+ }
+
updateEngineState();
}
@@ -161,6 +167,15 @@ double EffectParameter::getMaximum() const {
}
void EffectParameter::setMaximum(double maximum) {
+ // There's a degenerate case here where the minimum could be larger
+ // than the manifest maximum. If that's the case, then the maximum
+ // value is currently above the manifest maximum. Since similar
+ // guards exist in the setMinimum call, this should not be able to
+ // happen.
+ DEBUG_ASSERT_AND_HANDLE(m_maximum <= m_parameter.getMaximum()) {
+ return;
+ }
+
m_maximum = maximum;
if (m_maximum > m_parameter.getMaximum()) {
qWarning() << debugString() << "WARNING: Maximum value is less than plugin's absolute maximum, clamping.";
@@ -172,13 +187,6 @@ void EffectParameter::setMaximum(double maximum) {
m_maximum = m_minimum;
}
- // There's a degenerate case here where the minimum could be larger
- // than the manifest maximum. If that's the case, then the maximum
- // value is currently above the manifest maximum. Since similar
- // guards exist in the setMinimum call, this should not be able to
- // happen.
- Q_ASSERT(m_maximum <= m_parameter.getMaximum());
-
if (clampValue()) {
qWarning() << debugString() << "WARNING: Value was outside of new maximum, clamped.";
}
diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp
index dcb12ab2d4..3c698004a1 100644
--- a/src/effects/effectsmanager.cpp
+++ b/src/effects/effectsmanager.cpp
@@ -5,6 +5,7 @@
#include "engine/effects/engineeffectsmanager.h"
#include "engine/effects/engineeffect.h"
+#include "util/assert.h"
const char* kEqualizerRackName = "[EqualizerChain]";
const char* kQuickEffectRackName = "[QuickEffectChain]";
@@ -47,7 +48,9 @@ EffectsManager::~EffectsManager() {
}
void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) {
- Q_ASSERT(pBackend);
+ DEBUG_ASSERT_AND_HANDLE(pBackend) {
+ return;
+ }
m_effectsBackends.append(pBackend);
connect(pBackend, SIGNAL(effectRegistered()),
this, SIGNAL(availableEffectsUpdated()));
diff --git a/src/engine/enginebuffer.cpp b/src/engine/enginebuffer.cpp
index acd807147a..a62cd95824 100644
--- a/src/engine/enginebuffer.cpp
+++ b/src/engine/enginebuffer.cpp
@@ -51,6 +51,7 @@
#include "track/keyutils.h"
#include "controlobjectslave.h"
#include "util/compatibility.h"
+#include "util/assert.h"
#ifdef __VINYLCONTROL__
#include "engine/vinylcontrolcontrol.h"
@@ -715,9 +716,11 @@ void EngineBuffer::slotKeylockEngineChanged(double d_index) {
}
-void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize)
-{
- Q_ASSERT(even(iBufferSize));
+void EngineBuffer::process(CSAMPLE* pOutput, const int iBufferSize) {
+ // Bail if we receive a non-even buffer size. Assert in debug builds.
+ DEBUG_ASSERT_AND_HANDLE(even(iBufferSize)) {
+ return;
+ }
m_pReader->process();
// Steps:
// - Lookup new reader information
diff --git a/src/engine/enginebufferscalelinear.cpp b/src/engine/enginebufferscalelinear.cpp
index 0bade7e091..7c79564cb5 100644
--- a/src/engine/enginebufferscalelinear.cpp
+++ b/src/engine/enginebufferscalelinear.cpp
@@ -21,6 +21,7 @@
#include "sampleutil.h"
#include "track/keyutils.h"
#include "util/math.h"
+#include "util/assert.h"
EngineBufferScaleLinear::EngineBufferScaleLinear(ReadAheadManager *pReadAheadManager)
: EngineBufferScale(),
@@ -316,7 +317,6 @@ CSAMPLE* EngineBufferScaleLinear::do_scale(CSAMPLE* buf,
while (static_cast<int>(ceil(m_dCurSampleIndex)) * 2 + 1 >=
buffer_int_size) {
int old_bufsize = buffer_int_size;
- //Q_ASSERT(unscaled_samples_needed > 0);
if (unscaled_samples_needed == 0) {
unscaled_samples_needed = 2;
screwups++;
diff --git a/src/engine/enginedelay.cpp b/src/engine/enginedelay.cpp
index 984bd25d50..772a2b79ba 100644
--- a/src/engine/enginedelay.cpp
+++ b/src/engine/enginedelay.cpp
@@ -18,6 +18,7 @@
#include "controlpotmeter.h"
#include "controlobjectslave.h"
#include "sampleutil.h"
+#include "util/assert.h"
const int kiMaxDelay = 40000; // 208 ms @ 96 kb/s
const double kdMaxDelayPot = 200; // 200 ms
@@ -61,8 +62,12 @@ void EngineDelay::process(CSAMPLE* pInOut, const int iBufferSize) {
if (m_iDelay > 0) {
int iDelaySourcePos = (m_iDelayPos + kiMaxDelay - m_iDelay) % kiMaxDelay;
- Q_ASSERT(iDelaySourcePos >= 0);
- Q_ASSERT(iDelaySourcePos <= kiMaxDelay);
+ DEBUG_ASSERT_AND_HANDLE(iDelaySourcePos >= 0) {
+ return;
+ }
+ DEBUG_ASSERT_AND_HANDLE(iDelaySourcePos <= kiMaxDelay) {
+ return;
+ }
for (int i = 0; i < iBufferSize; ++i) {
// put sample into delay buffer:
diff --git a/src/engine/enginefilterdelay.h b/src/engine/enginefilterdelay.h
index 08ce03d7ed..77c24be7c1 100644
--- a/src/engine/enginefilterdelay.h
+++ b/src/engine/enginefilterdelay.h
@@ -4,6 +4,7 @@
#include <string.h>
#include "engine/engineobject.h"
+#include "util/assert.h"
template<unsigned int SIZE>
class EngineFilterDelay : public EngineObjectConstIn {
@@ -39,8 +40,14 @@ class EngineFilterDelay : public EngineObjectConstIn {
if (!m_doRamping) {
int delaySourcePos = (m_delayPos + SIZE - m_delaySamples) % SIZE;
- Q_ASSERT(delaySourcePos >= 0);
- Q_ASSERT(delaySourcePos <= static_cast<int>(SIZE));
+ DEBUG_ASSERT_AND_HANDLE(delaySourcePos >= 0) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
+ DEBUG_ASSERT_AND_HANDLE(delaySourcePos <= static_cast<int>(SIZE)) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
for (int i = 0; i < iBufferSize; ++i) {
// put sample into delay buffer:
@@ -55,8 +62,22 @@ class EngineFilterDelay : public EngineObjectConstIn {
int delaySourcePos = (m_delayPos + SIZE - m_delaySamples + iBufferSize / 2) % SIZE;
int oldDelaySourcePos = (m_delayPos + SIZE - m_oldDelaySamples) % SIZE;
- Q_ASSERT(delaySourcePos >= 0);
- Q_ASSERT(delaySourcePos <= static_cast<int>(SIZE));
+ DEBUG_ASSERT_AND_HANDLE(delaySourcePos >= 0) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
+ DEBUG_ASSERT_AND_HANDLE(delaySourcePos <= static_cast<int>(SIZE)) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
+ DEBUG_ASSERT_AND_HANDLE(oldDelaySourcePos >= 0) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
+ DEBUG_ASSERT_AND_HANDLE(oldDelaySourcePos <= static_cast<int>(SIZE)) {
+ SampleUtil::copy(pOutput, pIn, iBufferSize);
+ return;
+ }
double cross_mix = 0.0;
double cross_inc = 2 / static_cast<double>(iBufferSize);
diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp
index becdc81455..0edfff77eb 100644
--- a/src/engine/sync/enginesync.cpp
+++ b/src/engine/sync/enginesync.cpp
@@ -21,6 +21,7 @@
#include <QStringList>
#include "engine/sync/internalclock.h"
+#include "util/assert.h"
EngineSync::EngineSync(ConfigObject<ConfigValue>* pConfig)
: BaseSyncableListener(pConfig) {
@@ -32,7 +33,9 @@ EngineSync::~EngineSync() {
void EngineSync::requestSyncMode(Syncable* pSyncable, SyncMode mode) {
//qDebug() << "EngineSync::requestSyncMode" << pSyncable->getGroup() << mode;
// Based on the call hierarchy I don't think this is possible. (Famous last words.)
- Q_ASSERT(pSyncable);
+ DEBUG_ASSERT_AND_HANDLE(pSyncable) {
+ return;
+ }
const bool channelIsMaster = m_pMasterSyncable == pSyncable;
diff --git a/src/engine/sync/synccontrol.cpp b/src/engine/sync/synccontrol.cpp
index 195a95d335..27939862b8 100644
--- a/src/engine/sync/synccontrol.cpp
+++ b/src/engine/sync/synccontrol.cpp
@@ -8,6 +8,7 @@
#include "engine/enginechannel.h"
#include "engine/ratecontrol.h"
#include "util/math.h"
+#include "util/assert.h"
const double kTrackPositionMasterHandoff = 0.99;
@@ -105,7 +106,7 @@ void SyncControl::setEngineControls(RateControl* pRateControl,
// Throw a hissy fit if somebody moved us such that the vinylcontrol_enabled
// control doesn't exist yet. This will blow up immediately, won't go unnoticed.
- Q_ASSERT(m_pVCEnabled->valid());
+ DEBUG_ASSERT(m_pVCEnabled->valid());
m_pVCEnabled->connectValueChanged(this, SLOT(slotVinylControlChanged(double)),
Qt::DirectConnection);
diff --git a/src/errordialoghandler.cpp b/src/errordialoghandler.cpp
index 024aac4863..fbc0ca8653 100644
--- a/src/errordialoghandler.cpp
+++ b/src/errordialoghandler.cpp
@@ -22,6 +22,7 @@
#include <QtDebug>
#include "errordialoghandler.h"
+#include "util/assert.h"
ErrorDialogProperties::ErrorDialogProperties()
: m_title("Mixxx"),
@@ -108,7 +109,9 @@ bool ErrorDialogHandler::requestErrorDialog(DialogType type, QString message,
bool ErrorDialogHandler::requestErrorDialog(ErrorDialogProperties* props) {
// Make sure the minimum items are set
QString text = props->getText();
- Q_ASSERT(!text.isEmpty());
+ DEBUG_ASSERT_AND_HANDLE(!text.isEmpty()) {
+ return false;
+ }
// Skip if a dialog with the same key is already displayed
QMutexLocker locker(&m_mutex);
diff --git a/src/library/baseplaylistfeature.cpp b/src/library/baseplaylistfeature.cpp
index b1e9e23f92..35d9980ce2 100644
--- a/src/library/baseplaylistfeature.cpp
+++ b/src/library/baseplaylistfeature.cpp
@@ -15,6 +15,7 @@
#include "mixxxkeyboard.h"
#include "widget/wlibrary.h"
#include "widget/wlibrarytextbrowser.h"
+#include "util/assert.h"
BasePlaylistFeature::BasePlaylistFeature(QObject* parent,
ConfigObject<ConfigValue>* pConfig,
@@ -298,7 +299,9 @@ void BasePlaylistFeature::slotDeletePlaylist() {
}
if (m_lastRightClickedIndex.isValid()) {
- Q_ASSERT(playlistId >= 0);
+ DEBUG_ASSERT_AND_HANDLE(playlistId >= 0) {
+ return;
+ }
m_playlistDao.deletePlaylist(playlistId);
activate();
diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp
index cd5195992c..61484e9839 100644
--- a/src/library/basesqltablemodel.cpp
+++ b/src/library/basesqltablemodel.cpp
@@ -18,6 +18,7 @@
#include "track/keyutils.h"
#include "util/time.h"
#include "util/dnd.h"
+#include "util/assert.h"
const bool sDebug = false;
@@ -251,8 +252,9 @@ void BaseSqlTableModel::select() {
QLinkedList<int> tableColumnIndices;
foreach (QString column, m_tableColumns) {
- Q_ASSERT(record.indexOf(column) == m_tableColumnCache.fieldIndex(column));
- tableColumnIndices.push_back(record.indexOf(column));
+ int recordIndex = record.indexOf(column);
+ DEBUG_ASSERT(recordIndex == m_tableColumnCache.fieldIndex(column));
+ tableColumnIndices.push_back(recordIndex);
}
// sqlite does not set size and m_rowInfo was just cleared
diff --git a/src/library/dao/cue.cpp b/src/library/dao/cue.cpp
index 4eb0d4ff6e..e6d3351f5e 100644
--- a/src/library/dao/cue.cpp
+++ b/src/library/dao/cue.cpp
@@ -5,6 +5,7 @@
#include <QtDebug>
#include "library/dao/cue.h"
+#include "util/assert.h"
Cue::~Cue() {
qDebug() << "~Cue()" << m_iId;
@@ -85,8 +86,10 @@ int Cue::getPosition() {
}
void Cue::setPosition(int position) {
+ DEBUG_ASSERT_AND_HANDLE(position % 2 == 0) {
+ return;
+ }
QMutexLocker lock(&m_mutex);
- Q_ASSERT(position % 2 == 0);
m_iPosition = position;
m_bDirty = true;
lock.unlock();
@@ -100,8 +103,10 @@ int Cue::getLength() {
}
void Cue::setLength(int length) {
+ DEBUG_ASSERT_AND_HANDLE(length % 2 == 0) {
+ return;
+ }
QMutexLocker lock(&m_mutex);
- Q_ASSERT(length % 2 == 0);
m_iLength = length;
m_bDirty = true;
lock.unlock();
diff --git a/src/library/dao/cuedao.cpp b/src/library/dao/cuedao.cpp
index fb1d27b177..dc67c77238 100644
--- a/src/library/dao/cuedao.cpp
+++ b/src/library/dao/cuedao.cpp
@@ -9,6 +9,7 @@
#include "library/dao/cue.h"
#include "trackinfoobject.h"
#include "library/queryutil.h"
+#include "util/assert.h"
CueDAO::CueDAO(QSqlDatabase& database)
: m_database(database) {
@@ -140,7 +141,9 @@ bool CueDAO::deleteCuesForTracks(const QList<int>& ids) {
bool CueDAO::saveCue(Cue* cue) {
//qDebug() << "CueDAO::saveCue" << QThread::currentThread() << m_database.connectionName();
- Q_ASSERT(cue);
+ DEBUG_ASSERT_AND_HANDLE(cue) {
+ return false;
+ }
if (cue->getId() == -1) {
// New cue
QSqlQuery query(m_database);
diff --git a/src/library/dao/trackdao.cpp b/src/library/dao/trackdao.cpp
index b6918e2542..78bad952ea 100644
--- a/src/library/dao/trackdao.cpp
+++ b/src/library/dao/trackdao.cpp
@@ -23,6 +23,7 @@
#include "library/dao/analysisdao.h"
#include "library/dao/libraryhashdao.h"
#include "library/coverartcache.h"
+#include "util/assert.h"
QHash<int, TrackWeakPointer> TrackDAO::m_sTracks;
QMutex TrackDAO::m_sTracksMutex;
@@ -560,11 +561,13 @@ bool TrackDAO::addTracksAdd(TrackInfoObject* pTrack, bool unremove) {
QVariant lastInsert = m_pQueryTrackLocationInsert->lastInsertId();
trackLocationId = lastInsert.toInt();
- //Failure of this assert indicates that we were unable to insert the track
- //location into the table AND we could not retrieve the id of that track
- //location from the same table. "It shouldn't happen"... unless I screwed up
- //- Albert :)
- Q_ASSERT(trackLocationId >= 0);
+ // Failure of this assert indicates that we were unable to insert the
+ // track location into the table AND we could not retrieve the id of
+ // that track location from the same table. "It shouldn't
+ // happen"... unless I screwed up - Albert :)
+ DEBUG_ASSERT_AND_HANDLE(trackLocationId >= 0) {
+ return false;
+ }
bindTrackToLibraryInsert(pTrack, trackLocationId);
@@ -606,7 +609,10 @@ int TrackDAO::addTrack(const QString& file, bool unremove) {
void TrackDAO::addTrack(TrackInfoObject* pTrack, bool unremove) {
//qDebug() << "TrackDAO::addTrack" << QThread::currentThread() << m_database.connectionName();
//qDebug() << "TrackCollection::addTrack(), inserting into DB";
- Q_ASSERT(pTrack); //Why you be giving me NULL pTracks
+ // Why you be giving me NULL pTracks
+ DEBUG_ASSERT_AND_HANDLE(pTrack) {
+ return;
+ }
// Check that track is a supported extension.
if (!isTrackFormatSupported(pTrack)) {
@@ -878,7 +884,11 @@ void TrackDAO::purgeTracks(const QList<int>& ids) {
}
void TrackDAO::slotTrackDeleted(TrackInfoObject* pTrack) {
- Q_ASSERT(pTrack);
+ // Should not be possible.
+ DEBUG_ASSERT_AND_HANDLE(pTrack != NULL) {
+ return;
+ }
+
//qDebug() << "Garbage Collecting" << pTrack << "ID" << pTrack->getId() << pTrack->getInfo();
// Save the track if it is dirty.
@@ -1165,16 +1175,21 @@ TrackPointer TrackDAO::getTrack(const int id, const bool cacheOnly) const {
// Saves a track's info back to the database
void TrackDAO::updateTrack(TrackInfoObject* pTrack) {
+ DEBUG_ASSERT_AND_HANDLE(pTrack) {
+ return;
+ }
+
ScopedTransaction transaction(m_database);
QTime time;
time.start();
- Q_ASSERT(