From 4ecdb004e81a459ea63ebd7127e1c945df43f9ce Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Jul 2017 18:55:36 +0300 Subject: Fix issues detected by coverity. --- src/gui/widgets/guitable.cpp | 5 ++++- src/gui/widgets/staticbrowserbox.cpp | 6 +----- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 392755a20..9ff2075b1 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -593,6 +593,9 @@ void GuiTable::modelUpdated(const bool completed) Widget *GuiTable::getWidgetAt(int x, int y) { + if (mModel == nullptr) + return nullptr; + const int row = getRowForY(y); const int column = getColumnForX(x); @@ -602,7 +605,7 @@ Widget *GuiTable::getWidgetAt(int x, int y) return mTopWidget; } - if ((mModel != nullptr) && row > -1 && column > -1) + if (row > -1 && column > -1) { Widget *const w = mModel->getElementAt(row, column); if ((w != nullptr) && w->isFocusable()) diff --git a/src/gui/widgets/staticbrowserbox.cpp b/src/gui/widgets/staticbrowserbox.cpp index 7be4b780e..5999b2adf 100644 --- a/src/gui/widgets/staticbrowserbox.cpp +++ b/src/gui/widgets/staticbrowserbox.cpp @@ -668,16 +668,12 @@ void StaticBrowserBox::updateHeight() break; std::string part = row.substr(start, len); - int width = 0; - if (bold) - width = boldFont->getWidth(part); - else - width = font->getWidth(part); mLineParts.push_back(LinePart(CAST_S32(x), CAST_S32(y) + mItemPadding, selColor[0], selColor[1], part.c_str(), bold)); + int width = 0; if (bold) width = boldFont->getWidth(part); else -- cgit v1.2.3-70-g09d2