aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-03-06 16:40:23 -0600
committerColin Snover2016-03-06 21:34:43 -0600
commit36800b701764222ec0c527f68504d1d3dc2e1fcc (patch)
treebc2cd25a328a3301e0207ce380487f276068f7df
parent3e631ca5e3a3e19cb08be83c039ae9681a2e6cbc (diff)
downloadscummvm-rg350-36800b701764222ec0c527f68504d1d3dc2e1fcc.tar.gz
scummvm-rg350-36800b701764222ec0c527f68504d1d3dc2e1fcc.tar.bz2
scummvm-rg350-36800b701764222ec0c527f68504d1d3dc2e1fcc.zip
SCI32: Fix memory leaks
-rw-r--r--engines/sci/graphics/celobj32.cpp8
-rw-r--r--engines/sci/graphics/controls32.cpp5
-rw-r--r--engines/sci/graphics/controls32.h1
-rw-r--r--engines/sci/graphics/frameout.cpp3
-rw-r--r--engines/sci/graphics/plane32.cpp10
-rw-r--r--engines/sci/graphics/plane32.h3
-rw-r--r--engines/sci/graphics/screen_item32.cpp4
-rw-r--r--engines/sci/graphics/screen_item32.h1
8 files changed, 27 insertions, 8 deletions
diff --git a/engines/sci/graphics/celobj32.cpp b/engines/sci/graphics/celobj32.cpp
index 787d295d5e..b839b44e92 100644
--- a/engines/sci/graphics/celobj32.cpp
+++ b/engines/sci/graphics/celobj32.cpp
@@ -84,10 +84,9 @@ const CelScalerTable *CelScaler::getScalerTable(const Ratio &scaleX, const Ratio
#pragma mark CelObj
void CelObj::init() {
+ CelObj::deinit();
_nextCacheId = 1;
- delete _scaler;
_scaler = new CelScaler();
- delete _cache;
_cache = new CelCache;
_cache->resize(100);
}
@@ -95,6 +94,11 @@ void CelObj::init() {
void CelObj::deinit() {
delete _scaler;
_scaler = nullptr;
+ if (_cache != nullptr) {
+ for (CelCache::iterator it = _cache->begin(); it != _cache->end(); ++it) {
+ delete it->celObj;
+ }
+ }
delete _cache;
_cache = nullptr;
}
diff --git a/engines/sci/graphics/controls32.cpp b/engines/sci/graphics/controls32.cpp
index fc028f7584..8d9f8a708f 100644
--- a/engines/sci/graphics/controls32.cpp
+++ b/engines/sci/graphics/controls32.cpp
@@ -43,8 +43,6 @@ GfxControls32::GfxControls32(SegManager *segMan, GfxCache *cache, GfxText32 *tex
_overwriteMode(false),
_nextCursorFlashTick(0) {}
-GfxControls32::~GfxControls32() {}
-
reg_t GfxControls32::kernelEditText(const reg_t controlObject) {
SegManager *segMan = _segMan;
@@ -149,7 +147,8 @@ reg_t GfxControls32::kernelEditText(const reg_t controlObject) {
bool focused = true;
// Original engine did not have a QUIT event but we have to handle it
if (event.type == SCI_EVENT_QUIT) {
- return NULL_REG;
+ focused = false;
+ break;
} else if (event.type == SCI_EVENT_MOUSE_PRESS && !editorPlaneRect.contains(event.mousePosSci)) {
focused = false;
} else if (event.type == SCI_EVENT_KEYBOARD) {
diff --git a/engines/sci/graphics/controls32.h b/engines/sci/graphics/controls32.h
index 0dc3b9ce6f..1bb7679ddd 100644
--- a/engines/sci/graphics/controls32.h
+++ b/engines/sci/graphics/controls32.h
@@ -105,7 +105,6 @@ struct TextEditor {
class GfxControls32 {
public:
GfxControls32(SegManager *segMan, GfxCache *cache, GfxText32 *text);
- ~GfxControls32();
reg_t kernelEditText(const reg_t controlObject);
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 55f5b36f56..19eaeef087 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -133,8 +133,9 @@ GfxFrameout::GfxFrameout(SegManager *segMan, ResourceManager *resMan, GfxCoordAd
}
GfxFrameout::~GfxFrameout() {
- CelObj::deinit();
clear();
+ CelObj::deinit();
+ free(_currentBuffer.getPixels());
}
void GfxFrameout::run() {
diff --git a/engines/sci/graphics/plane32.cpp b/engines/sci/graphics/plane32.cpp
index 0a0b0ad561..de82a40f9e 100644
--- a/engines/sci/graphics/plane32.cpp
+++ b/engines/sci/graphics/plane32.cpp
@@ -55,6 +55,7 @@ _redrawAllCount(g_sci->_gfxFrameout->getScreenCount()),
_created(g_sci->_gfxFrameout->getScreenCount()),
_updated(0),
_deleted(0),
+_moved(0),
_gameRect(gameRect) {
convertGameRectToPlaneRect();
_priority = MAX(10000, g_sci->_gfxFrameout->getPlanes().getTopPlanePriority() + 1);
@@ -808,6 +809,11 @@ void PlaneList::erase(Plane *plane) {
}
}
+PlaneList::iterator PlaneList::erase(iterator it) {
+ delete *it;
+ return PlaneListBase::erase(it);
+}
+
int PlaneList::findIndexByObject(const reg_t object) const {
for (size_type i = 0; i < size(); ++i) {
if ((*this)[i] != nullptr && (*this)[i]->_object == object) {
@@ -850,6 +856,10 @@ int16 PlaneList::getTopSciPlanePriority() const {
return priority;
}
+void PlaneList::remove_at(size_type index) {
+ delete PlaneListBase::remove_at(index);
+}
+
void PlaneList::add(Plane *plane) {
for (iterator it = begin(); it != end(); ++it) {
if ((*it)->_priority > plane->_priority) {
diff --git a/engines/sci/graphics/plane32.h b/engines/sci/graphics/plane32.h
index c9b9d6a099..f60f0cc72b 100644
--- a/engines/sci/graphics/plane32.h
+++ b/engines/sci/graphics/plane32.h
@@ -480,11 +480,12 @@ public:
void add(Plane *plane);
void clear();
- using PlaneListBase::erase;
+ iterator erase(iterator it);
void erase(Plane *plane);
inline void sort() {
Common::sort(begin(), end(), sortHelper);
}
+ void remove_at(size_type index);
};
}
diff --git a/engines/sci/graphics/screen_item32.cpp b/engines/sci/graphics/screen_item32.cpp
index ae0b83bcff..f3f397d632 100644
--- a/engines/sci/graphics/screen_item32.cpp
+++ b/engines/sci/graphics/screen_item32.cpp
@@ -126,6 +126,10 @@ void ScreenItem::operator=(const ScreenItem &other) {
_scaledPosition = other._scaledPosition;
}
+ScreenItem::~ScreenItem() {
+ delete _celObj;
+}
+
void ScreenItem::init() {
_nextObjectId = 20000;
}
diff --git a/engines/sci/graphics/screen_item32.h b/engines/sci/graphics/screen_item32.h
index 1c4d87d24c..e86efdaf6a 100644
--- a/engines/sci/graphics/screen_item32.h
+++ b/engines/sci/graphics/screen_item32.h
@@ -215,6 +215,7 @@ public:
ScreenItem(const reg_t plane, const CelInfo32 &celInfo, const Common::Rect &rect);
ScreenItem(const reg_t plane, const CelInfo32 &celInfo, const Common::Point &position, const ScaleInfo &scaleInfo);
ScreenItem(const ScreenItem &other);
+ ~ScreenItem();
void operator=(const ScreenItem &);
inline bool operator<(const ScreenItem &other) const {