From e4fdc288fe7d56080922305ba7c55a378d505d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 3 Jun 2022 17:11:34 +0200 Subject: [PATCH] Clean up some DEBUG_ASSERTS --- src/library/basesqltablemodel.cpp | 17 +++++++++-------- src/library/treeitem.cpp | 3 +-- src/skin/skinloader.cpp | 2 +- src/vinylcontrol/vinylcontrolmanager.cpp | 3 +-- src/widget/wmainmenubar.cpp | 3 +-- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/library/basesqltablemodel.cpp b/src/library/basesqltablemodel.cpp index ae539e3aa7c1..cb79f50373ee 100644 --- a/src/library/basesqltablemodel.cpp +++ b/src/library/basesqltablemodel.cpp @@ -252,15 +252,17 @@ void BaseSqlTableModel::select() { if (idColumn < 0) { idColumn = sqlRecord.indexOf(m_idColumn); } + + // TODO(XXX): Can we get rid of the hard-coded assumption that + // the the first column always contains the id? + DEBUG_ASSERT(idColumn == kIdColumn); + VERIFY_OR_DEBUG_ASSERT(idColumn >= 0) { qCritical() << "ID column not available in database query results:" << m_idColumn; return; } - // TODO(XXX): Can we get rid of the hard-coded assumption that - // the the first column always contains the id? - DEBUG_ASSERT(idColumn == kIdColumn); TrackId trackId(sqlRecord.value(idColumn)); trackIds.insert(trackId); @@ -741,11 +743,10 @@ bool BaseSqlTableModel::setTrackValueForColumn( pTrack->setBpmLocked(value.toBool()); } else { // We never should get up to this point! - VERIFY_OR_DEBUG_ASSERT(false) { - qWarning() << "Column" - << columnNameForFieldIndex(column) - << "is not editable!"; - } + qWarning() << "Column" + << columnNameForFieldIndex(column) + << "is not editable!"; + DEBUG_ASSERT(false); return false; } return true; diff --git a/src/library/treeitem.cpp b/src/library/treeitem.cpp index c7db2a6be4e7..3acae37a258d 100644 --- a/src/library/treeitem.cpp +++ b/src/library/treeitem.cpp @@ -69,13 +69,12 @@ void TreeItem::insertChild(int row, TreeItem* pChild) { } void TreeItem::initFeatureRecursively(LibraryFeature* pFeature) { - DEBUG_ASSERT(!m_pFeature || - m_pFeature == pFeature); DEBUG_ASSERT(!m_pParent || m_pParent->m_pFeature == pFeature); if (m_pFeature == pFeature) { return; } + DEBUG_ASSERT(!m_pFeature); m_pFeature = pFeature; for (auto* pChild : qAsConst(m_children)) { pChild->initFeatureRecursively(pFeature); diff --git a/src/skin/skinloader.cpp b/src/skin/skinloader.cpp index 7e77babad4be..5a46ae8dfaa5 100644 --- a/src/skin/skinloader.cpp +++ b/src/skin/skinloader.cpp @@ -167,7 +167,7 @@ QWidget* SkinLoader::loadConfiguredSkin(QWidget* pParent, // This might also fail, but pLoadedSkin = pSkin->loadSkin(pParent, m_pConfig, pSkinCreatedControls, pCoreServices); } - DEBUG_ASSERT(pLoadedSkin != nullptr); + DEBUG_ASSERT(pLoadedSkin); } VERIFY_OR_DEBUG_ASSERT(pLoadedSkin != nullptr) { diff --git a/src/vinylcontrol/vinylcontrolmanager.cpp b/src/vinylcontrol/vinylcontrolmanager.cpp index 44d73be71a80..d2faaeb34293 100644 --- a/src/vinylcontrol/vinylcontrolmanager.cpp +++ b/src/vinylcontrol/vinylcontrolmanager.cpp @@ -103,8 +103,7 @@ void VinylControlManager::slotNumDecksChanged(double dNumDecks) { } void VinylControlManager::slotVinylControlEnabledChanged(int deck) { - if (deck < 0 || deck >= m_pVcEnabled.size()) { - DEBUG_ASSERT(false); + VERIFY_OR_DEBUG_ASSERT(deck >= 0 && deck < m_pVcEnabled.size()) { return; } diff --git a/src/widget/wmainmenubar.cpp b/src/widget/wmainmenubar.cpp index 07c75aad144d..e217c7c86972 100644 --- a/src/widget/wmainmenubar.cpp +++ b/src/widget/wmainmenubar.cpp @@ -681,8 +681,7 @@ void WMainMenuBar::onFullScreenStateChange(bool fullscreen) { } void WMainMenuBar::onVinylControlDeckEnabledStateChange(int deck, bool enabled) { - if (deck < 0 || deck >= m_vinylControlEnabledActions.size()) { - DEBUG_ASSERT(false); + VERIFY_OR_DEBUG_ASSERT(deck >= 0 && deck < m_vinylControlEnabledActions.size()) { return; } m_vinylControlEnabledActions.at(deck)->setChecked(enabled);