From a3e2208ae3b2190b3f176a7cf52d65bb4d42d82d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 14 Jan 2013 22:21:53 +0100 Subject: Coverity report fixes A potential crash (dynamic_cast maybe null) Some break usage clean up minor string speed up by using QLatin1String --- src/history/historymodels.cpp | 14 ++++++++------ src/tabwindow/tabhighlighteffect.cpp | 2 +- src/urlbar/bookmarkwidget.cpp | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp index 4888ca42..775aa320 100644 --- a/src/history/historymodels.cpp +++ b/src/history/historymodels.cpp @@ -137,24 +137,26 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const case 1: return item.url; } + break; } case Qt::DecorationRole: if (index.column() == 0) { return IconManager::self()->iconForUrl(item.url); } + break; case Qt::ToolTipRole: - QString tooltip = ""; + QString tooltip; if (!item.title.isEmpty()) - tooltip = item.title + "
"; + tooltip = item.title + QL1S("
"); QString lastVisit = item.firstDateTimeVisit.toString(Qt::SystemLocaleDate); QString firstVisit = item.lastDateTimeVisit.toString(Qt::SystemLocaleDate); int visitCount = item.visitCount; - tooltip += "
" + item.url + "
"; - tooltip += "
"; - tooltip += i18n("First Visit: ") + firstVisit + "
"; - tooltip += i18n("Last Visit: ") + lastVisit + "
"; + tooltip += QL1S("
") + item.url + QL1S("
"); + tooltip += QL1S("
"); + tooltip += i18n("First Visit: ") + firstVisit + QL1S("
"); + tooltip += i18n("Last Visit: ") + lastVisit + QL1S("
"); tooltip += i18n("Number of Visits: ") + QString::number(visitCount); return tooltip; diff --git a/src/tabwindow/tabhighlighteffect.cpp b/src/tabwindow/tabhighlighteffect.cpp index 121afd15..3913deca 100644 --- a/src/tabwindow/tabhighlighteffect.cpp +++ b/src/tabwindow/tabhighlighteffect.cpp @@ -89,7 +89,7 @@ bool TabHighlightEffect::event(QEvent* event) { QDynamicPropertyChangeEvent *pChangeEv = dynamic_cast(event); - if (pChangeEv->propertyName().startsWith(prep)) + if (pChangeEv && pChangeEv->propertyName().startsWith(prep)) { update(); return true; diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index e266a071..fc3139d0 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -64,6 +64,8 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) : QMenu(parent) , m_bookmark(new KBookmark(bookmark)) + , m_tagLine(new KLineEdit(this)) + , m_commentEdit(new QPlainTextEdit(this)) { setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(320); @@ -137,7 +139,6 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) QLabel *commentLabel = new QLabel(this); commentLabel->setText(i18n("Describe:")); commentLabel->setAlignment(Qt::AlignCenter); - m_commentEdit = new QPlainTextEdit(this); if (!m_nfoResource.description().isEmpty()) { m_commentEdit->setPlainText(m_nfoResource.description()); @@ -149,7 +150,6 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) QLabel *tagLabel = new QLabel(this); tagLabel->setText(i18n("Tags:")); tagLabel->setAlignment(Qt::AlignLeft); - m_tagLine = new KLineEdit(this); m_tagLine->setPlaceholderText(i18n("add tags(comma separated)")); -- cgit v1.2.1