summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-11-26 13:21:25 +0000
committerrubidium <rubidium@openttd.org>2013-11-26 13:21:25 +0000
commit50fdf5e30cd59090fb6600f0fbae8888c43ca7ee (patch)
treee9cb57fc65007dd4336da4569225b91311e8c910 /src/widget.cpp
parent945fccc706e6ea175e7a112fb78ce1217e7464d5 (diff)
downloadopenttd-50fdf5e30cd59090fb6600f0fbae8888c43ca7ee.tar.xz
(svn r26121) -Codechange: add some asserts after dynamic casts to show they shouldn't return NULL ever
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 839ee98ce..6e73fd449 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -147,7 +147,9 @@ void ScrollbarClickHandler(Window *w, NWidgetCore *nw, int x, int y)
mi = nw->pos_y;
ma = nw->pos_y + nw->current_y;
}
- ScrollbarClickPositioning(w, dynamic_cast<NWidgetScrollbar*>(nw), x, y, mi, ma);
+ NWidgetScrollbar *scrollbar = dynamic_cast<NWidgetScrollbar*>(nw);
+ assert(scrollbar != NULL);
+ ScrollbarClickPositioning(w, scrollbar, x, y, mi, ma);
}
/**
@@ -1526,7 +1528,9 @@ void NWidgetMatrix::SetupSmallestSize(Window *w, bool init_array)
}
/* Reset the widget number. */
- SB(dynamic_cast<NWidgetCore *>(this->head)->index, 16, 16, 0);
+ NWidgetCore *nw = dynamic_cast<NWidgetCore *>(this->head);
+ assert(nw != NULL);
+ SB(nw->index, 16, 16, 0);
this->head->SetupSmallestSize(w, init_array);
Dimension padding = {this->pip_pre + this->pip_post, this->pip_pre + this->pip_post};
@@ -1595,6 +1599,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y)
if (sub_wid >= this->count) return NULL;
NWidgetCore *child = dynamic_cast<NWidgetCore *>(this->head);
+ assert(child != NULL);
child->AssignSizePosition(ST_RESIZE,
this->pos_x + (rtl ? this->pip_post - widget_col * this->widget_w : this->pip_pre + widget_col * this->widget_w) + base_offs_x,
this->pos_y + this->pip_pre + widget_row * this->widget_h + base_offs_y,
@@ -1619,6 +1624,7 @@ NWidgetCore *NWidgetMatrix::GetWidgetFromPos(int x, int y)
/* Get the appropriate offsets so we can draw the right widgets. */
NWidgetCore *child = dynamic_cast<NWidgetCore *>(this->head);
+ assert(child != NULL);
int start_x, start_y, base_offs_x, base_offs_y;
this->GetScrollOffsets(start_x, start_y, base_offs_x, base_offs_y);