aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Haumann <dhaumann@kde.org>2014-01-24 14:09:25 (GMT)
committerDominik Haumann <dhaumann@kde.org>2014-01-24 14:09:25 (GMT)
commit1876076d6f37d82258317556ae0352fb83c5451d (patch)
tree94af51733ccc7600e0e7f59fc7f7bea84161e52c
parent6b58e3d4bf590d1030e58b107f01ab67fd04156f (diff)
do not tolerate wrong input: add asserts
-rw-r--r--kate/src/katetabbar.cpp56
1 files changed, 16 insertions, 40 deletions
diff --git a/kate/src/katetabbar.cpp b/kate/src/katetabbar.cpp
index f2f00c2..ed84ba8 100644
--- a/kate/src/katetabbar.cpp
+++ b/kate/src/katetabbar.cpp
@@ -153,9 +153,7 @@ int KateTabBar::currentTab() const
*/
void KateTabBar::setCurrentTab(int id)
{
- if (!m_idToTab.contains(id)) {
- return;
- }
+ Q_ASSERT(m_idToTab.contains(id));
KateTabButton *tabButton = m_idToTab[id];
if (m_activeButton == tabButton) {
@@ -176,10 +174,7 @@ void KateTabBar::setCurrentTab(int id)
*/
int KateTabBar::removeTab(int id)
{
- if (!m_idToTab.contains(id)) {
- Q_ASSERT(false);
- return -1;
- }
+ Q_ASSERT(m_idToTab.contains(id));
KateTabButton *tabButton = m_idToTab[id];
@@ -216,9 +211,7 @@ bool KateTabBar::containsTab(int id) const
*/
void KateTabBar::setTabText(int id, const QString &text)
{
- if (!m_idToTab.contains(id)) {
- return;
- }
+ Q_ASSERT(m_idToTab.contains(id));
// change highlight key, if entry exists
if (m_highlightedTabs.contains(m_idToTab[id]->text())) {
@@ -241,11 +234,8 @@ void KateTabBar::setTabText(int id, const QString &text)
*/
QString KateTabBar::tabText(int id) const
{
- if (m_idToTab.contains(id)) {
- return m_idToTab[id]->text();
- }
-
- return QString();
+ Q_ASSERT(m_idToTab.contains(id));
+ return m_idToTab[id]->text();
}
/**
@@ -253,10 +243,7 @@ QString KateTabBar::tabText(int id) const
*/
void KateTabBar::setTabToolTip(int id, const QString &tip)
{
- if (!m_idToTab.contains(id)) {
- return;
- }
-
+ Q_ASSERT(m_idToTab.contains(id));
m_idToTab[id]->setToolTip(tip);
}
@@ -265,11 +252,8 @@ void KateTabBar::setTabToolTip(int id, const QString &tip)
*/
QString KateTabBar::tabToolTip(int id) const
{
- if (m_idToTab.contains(id)) {
- return m_idToTab[id]->toolTip();
- }
-
- return QString();
+ Q_ASSERT(m_idToTab.contains(id));
+ return m_idToTab[id]->toolTip();
}
/**
@@ -278,9 +262,8 @@ QString KateTabBar::tabToolTip(int id) const
*/
void KateTabBar::setTabIcon(int id, const QIcon &icon)
{
- if (m_idToTab.contains(id)) {
- m_idToTab[id]->setIcon(icon);
- }
+ Q_ASSERT(m_idToTab.contains(id));
+ m_idToTab[id]->setIcon(icon);
}
/**
@@ -290,11 +273,8 @@ void KateTabBar::setTabIcon(int id, const QIcon &icon)
*/
QIcon KateTabBar::tabIcon(int id) const
{
- if (m_idToTab.contains(id)) {
- return m_idToTab[id]->icon();
- }
-
- return QIcon();
+ Q_ASSERT(m_idToTab.contains(id));
+ return m_idToTab[id]->icon();
}
/**
@@ -307,18 +287,14 @@ int KateTabBar::count() const
void KateTabBar::setTabModified(int id, bool modified)
{
- if (m_idToTab.contains(id)) {
- m_idToTab[id]->setModified(modified);
- }
+ Q_ASSERT(m_idToTab.contains(id));
+ m_idToTab[id]->setModified(modified);
}
bool KateTabBar::isTabModified(int id) const
{
- if (m_idToTab.contains(id)) {
- return m_idToTab[id]->isModified();
- }
-
- return false;
+ Q_ASSERT(m_idToTab.contains(id));
+ return m_idToTab[id]->isModified();
}
void KateTabBar::removeHighlightMarks()