diff options
author | rubidium <rubidium@openttd.org> | 2009-12-21 18:20:18 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-12-21 18:20:18 +0000 |
commit | 50734030aaf7ae43809e842b3f7cfcabca598a9e (patch) | |
tree | 5c40066cff4ead213df0bc0b3e7232aa59564e02 /src | |
parent | 38ceeb41b7c6b5fb6e0f83f28c3da8f90cf05862 (diff) | |
download | openttd-50734030aaf7ae43809e842b3f7cfcabca598a9e.tar.xz |
(svn r18593) -Fix: GetWidget call case similar to r18591
Diffstat (limited to 'src')
-rw-r--r-- | src/widget.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widget.cpp b/src/widget.cpp index a4c2338dd..e403b20c8 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -2090,7 +2090,11 @@ Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next) const if (this->type == WWT_SCROLL2BAR) return &w->vscroll2; if (this->index >= 0 && allow_next && (uint)(this->index) + 1 < w->nested_array_size) { - const NWidgetCore *next_wid = w->GetWidget<NWidgetCore>(this->index + 1); + /* GetWidget ensures that the widget is of the given type. + * As we might have cases where the next widget in the array + * is a non-Core widget (e.g. NWID_SELECTION) we first get + * the base class and then dynamic_cast that. */ + const NWidgetCore *next_wid = dynamic_cast<NWidgetCore*>(w->GetWidget<NWidgetBase>(this->index + 1)); if (next_wid != NULL) return next_wid->FindScrollbar(w, false); } return NULL; |