From 5181546c639b67fa821b849ca18e37f4bf846cb1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 9 Mar 2009 22:26:02 +0000 Subject: Rewrote Common::List iterator code to ensure const correctness is preserved. We tried to implement the list iterators in a clever way, to reduce code duplication. But this is essentially impossible to do properly, sadly -- this is one of the places where the ugly drawbacks of C++ really show. As a consequence, our implementation had a bug which allowed one to convert any const_iterator to an iterator, thus allowing modifying elements of const lists. This rewrite reintroduces code duplication but at least ensures that no const list is written to accidentally. Also fix some places which incorrectly used iterator instead of const_iterator or (in the kyra code) accidentally wrote into a const list. svn-id: r39279 --- engines/m4/viewmgr.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/m4/viewmgr.h') diff --git a/engines/m4/viewmgr.h b/engines/m4/viewmgr.h index 4c4f227c5c..38ed3635c4 100644 --- a/engines/m4/viewmgr.h +++ b/engines/m4/viewmgr.h @@ -26,6 +26,7 @@ #ifndef M4_VIEWMGR_H #define M4_VIEWMGR_H +#include "common/algorithm.h" #include "common/array.h" #include "common/list.h" #include "common/events.h" @@ -172,7 +173,7 @@ public: Common::List views() const { return _views; } bool contains(View *key) const { - return find(_views.begin(), _views.end(), key) != _views.end(); + return Common::find(_views.begin(), _views.end(), key) != _views.end(); } bool contains(int screenType) { return getView(screenType) != NULL; } View *getView(int screenType); -- cgit v1.2.3