aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMax Horn2009-05-05 12:33:11 +0000
committerMax Horn2009-05-05 12:33:11 +0000
commitdc29c404a755dd9583a35d129d73c2b904b43031 (patch)
tree2bbf2e56f9acf0da6f0b785021b482da8af5afc0 /engines/sci
parent61dcaad8886c9e1ced630eeab364f59cd27a4657 (diff)
downloadscummvm-rg350-dc29c404a755dd9583a35d129d73c2b904b43031.tar.gz
scummvm-rg350-dc29c404a755dd9583a35d129d73c2b904b43031.tar.bz2
scummvm-rg350-dc29c404a755dd9583a35d129d73c2b904b43031.zip
SCI: Work around an 'Array used after being disposed' bug that occurs when a GfxVisual gets disposed
svn-id: r40327
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/gfx/gfx_state_internal.h1
-rw-r--r--engines/sci/gfx/gfx_widgets.cpp15
2 files changed, 16 insertions, 0 deletions
diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h
index f6085b4a0e..8b1c443e86 100644
--- a/engines/sci/gfx/gfx_state_internal.h
+++ b/engines/sci/gfx/gfx_state_internal.h
@@ -340,6 +340,7 @@ struct GfxVisual : public GfxContainer {
public:
GfxVisual(GfxState *state, int font);
+ ~GfxVisual();
virtual int draw(const Common::Point &pos);
virtual void print(int indentation) const;
diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp
index a90458118c..71ff4d82ff 100644
--- a/engines/sci/gfx/gfx_widgets.cpp
+++ b/engines/sci/gfx/gfx_widgets.cpp
@@ -1461,6 +1461,21 @@ GfxVisual::GfxVisual(GfxState *state, int font)
_gfxw_set_ops_VISUAL(this);
}
+GfxVisual::~GfxVisual() {
+ // HACK: We must dispose all content *here* already, because our child widgets
+ // still may have references to this object, and will try to invoke methods
+ // of this object which try to access the already cleared _portRefs array
+ // when they are destroyed.
+ GfxWidget *seeker = _contents;
+
+ while (seeker) {
+ GfxWidget *next = seeker->_next;
+ delete seeker;
+ seeker = next;
+ }
+ _contents = 0;
+}
+
static int _visual_find_free_ID(GfxVisual *visual) {
uint id = 0;