=== modified file 'src/rail_gui.cpp' --- src/rail_gui.cpp 2008-04-22 18:36:42 +0000 +++ src/rail_gui.cpp 2008-04-30 13:48:31 +0000 @@ -748,7 +748,7 @@ if (!ValParamRailtype(railtype)) return; // don't recreate the window if we're clicking on a button and the window exists. - if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || w->wndproc != BuildRailToolbWndProc) { + if (button < 0 || !(w = FindWindowById(WC_BUILD_TOOLBAR, 0)) || !w->CompareWndprocEqual(BuildRailToolbWndProc)) { DeleteWindowById(WC_BUILD_TOOLBAR, 0); _cur_railtype = railtype; w = AllocateWindowDesc(&_build_rail_desc); @@ -1598,7 +1598,7 @@ Window *w; _last_built_railtype = _cur_railtype = RAILTYPE_RAIL; w = FindWindowById(WC_BUILD_TOOLBAR, 0); - if (w != NULL && w->wndproc == BuildRailToolbWndProc) { + if (w != NULL && w->CompareWndprocEqual(BuildRailToolbWndProc)) { SetupRailToolbar(_cur_railtype, w); SetWindowDirty(w); } @@ -1649,7 +1649,7 @@ _last_built_railtype = _cur_railtype = rt; Window *w = FindWindowById(WC_BUILD_TOOLBAR, 0); - if (w != NULL && w->wndproc == BuildRailToolbWndProc) { + if (w != NULL && w->CompareWndprocEqual(BuildRailToolbWndProc)) { SetupRailToolbar(_cur_railtype, w); SetWindowDirty(w); } === modified file 'src/window.cpp' --- src/window.cpp 2008-04-19 13:39:00 +0000 +++ src/window.cpp 2008-04-30 14:07:31 +0000 @@ -46,6 +46,19 @@ byte _special_mouse_mode; +/** + * Check whether the window uses a particular window event handler function + * @param proc Window handler function to compare with + * @return \c true if the window uses the provided window handler function, + * \c false if not + * + * @note The check is used as a way to distinguish between different windows + * in the same WC_BUILD_TOOLBAR window class + */ +bool Window::CompareWndprocEqual(WindowProc *proc) +{ + return wndproc == proc; +} void CDECL Window::SetWidgetsDisabledState(bool disab_stat, int widgets, ...) { === modified file 'src/window_gui.h' --- src/window_gui.h 2008-04-19 13:39:00 +0000 +++ src/window_gui.h 2008-04-30 13:46:27 +0000 @@ -339,6 +339,8 @@ void CDECL SetWidgetsHiddenState(bool hidden_stat, int widgets, ...); void CDECL SetWidgetsLoweredState(bool lowered_stat, int widgets, ...); void InvalidateWidget(byte widget_index) const; + + bool CompareWndprocEqual(WindowProc *proc); }; struct menu_d {