Core: Prevent possible nullptr access

I doubt that this can happen in practice, but better be save than sorry:-)

Change-Id: I30919e9ba16c2cc8cf401fc0c9f49267a215af71
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2016-12-05 15:47:55 +01:00
parent 1f7694135d
commit 8b9c6ba4b3

View File

@@ -25,6 +25,8 @@
#include "highlightscrollbar.h"
#include <utils/qtcassert.h>
#include <QPainter>
#include <QResizeEvent>
#include <QStyle>
@@ -252,7 +254,7 @@ void HighlightScrollBarOverlay::paintEvent(QPaintEvent *paintEvent)
int top = rect.top() + offset + verticalMargin + float(it.key()) / range * rect.height();
const int bottom = top + resultHeight;
if (previousCategory == currentCategory && previousBottom + 1 >= top) {
if (QTC_GUARD(previousRect) && previousCategory == currentCategory && previousBottom + 1 >= top) {
// If the previous highlight has the same category and is directly prior to this highlight
// we just extend the previous highlight.
previousRect->setBottom(bottom - 1);