From f8697e20b50607e93df0cf3ddf725d6fee6360cf Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 14 Aug 2010 08:03:32 +0000 Subject: SCI: now reusing window ids on kNewWindow sq4cd recreates the inventory window several times, but also reuses old window ids, causing kernelSetActive errors. fixes bug #3044757 svn-id: r52079 --- engines/sci/graphics/ports.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'engines/sci/graphics') diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index 2d8bfde37d..dddd9b1c86 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -288,6 +288,16 @@ Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restor // Find an unused window/port id uint id = PORTS_FIRSTWINDOWID; while (id < _windowsById.size() && _windowsById[id]) { + if (_windowsById[id]->counterTillFree) { + // port that is already disposed, but not freed yet + freeWindow((Window *)_windowsById[id]); + _freeCounter--; + break; // reuse the handle + // we do this especially for sq4cd. it creates and disposes the + // inventory window all the time, but reuses old handles as well + // this worked somewhat under the original interpreter, because + // it put the new window where the old was. + } ++id; } if (id == _windowsById.size()) -- cgit v1.2.3