aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVicent Marti2008-07-04 20:05:30 +0000
committerVicent Marti2008-07-04 20:05:30 +0000
commit96f2d9ca18eea27eaffda76fbce2168cddebbfb1 (patch)
tree14043c0e25e1e57f87928200c008a44dfac8e842
parent3b73b199a6006a84df06453335354e4e6728f6af (diff)
downloadscummvm-rg350-96f2d9ca18eea27eaffda76fbce2168cddebbfb1.tar.gz
scummvm-rg350-96f2d9ca18eea27eaffda76fbce2168cddebbfb1.tar.bz2
scummvm-rg350-96f2d9ca18eea27eaffda76fbce2168cddebbfb1.zip
Memory leaks.
Bug fixes. svn-id: r32908
-rw-r--r--common/xmlparser.cpp5
-rw-r--r--graphics/VectorRenderer.h13
-rw-r--r--gui/ThemeParser.cpp4
-rw-r--r--gui/ThemeRenderer.cpp13
-rw-r--r--gui/ThemeRenderer.h13
-rw-r--r--gui/newgui.cpp2
6 files changed, 22 insertions, 28 deletions
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 3452db9e00..d5c8535932 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -143,10 +143,7 @@ bool XMLParser::parse() {
_pos = 0;
_activeKey.clear();
- while (_text[_pos]) {
- if (_state == kParserError)
- break;
-
+ while (_text[_pos] && _state != kParserError) {
if (skipSpaces())
continue;
diff --git a/graphics/VectorRenderer.h b/graphics/VectorRenderer.h
index 0e679663d9..d6b315d2b3 100644
--- a/graphics/VectorRenderer.h
+++ b/graphics/VectorRenderer.h
@@ -535,22 +535,17 @@ public:
* @see VectorRenderer::copyFrame()
*/
virtual void copyFrame(OSystem *sys, const Common::Rect &r) {
-#ifdef OVERLAY_MULTIPLE_DEPTHS // TODO: change OSystem to support templated copyRectToOverlay
- sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(r.left, r.top),
- _activeSurface->w, r.top, r.left, r.width(), r.height());
-#else
- sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(r.left, r.top),
- _activeSurface->w, r.top, r.left, r.width(), r.height());
-#endif
+ sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(r.left, r.top),
+ _activeSurface->w, r.left, r.top, r.width(), r.height());
}
virtual void copyWholeFrame(OSystem *sys) {
#ifdef OVERLAY_MULTIPLE_DEPTHS
sys->copyRectToOverlay((const PixelType*)_activeSurface->getBasePtr(0, 0),
- _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
+ _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
#else
sys->copyRectToOverlay((const OverlayColor*)_activeSurface->getBasePtr(0, 0),
- _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
+ _activeSurface->w, 0, 0, _activeSurface->w, _activeSurface->h);
#endif
}
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index cd9ebc83a4..2726e15587 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -223,7 +223,9 @@ bool ThemeParser::parserCallback_DRAWSTEP() {
if (!parseDrawStep(stepNode, drawstep, true))
return false;
- _theme->addDrawStep(drawdataNode->values["id"], drawstep);
+ _theme->addDrawStep(drawdataNode->values["id"], *drawstep);
+ delete drawstep;
+
return true;
}
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index a5a1625fb6..d17698c9c1 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -99,7 +99,7 @@ bool ThemeRenderer::init() {
resetDrawArea();
}
- if (!_themeOk || isThemeLoadingRequired()) {
+ if (isThemeLoadingRequired() || !_themeOk) {
loadTheme(_themeName);
Theme::loadTheme(_defaultConfig);
@@ -173,7 +173,7 @@ void ThemeRenderer::setGraphicsMode(GraphicsMode mode) {
_vectorRenderer->setSurface(_screen);
}
-void ThemeRenderer::addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step) {
+void ThemeRenderer::addDrawStep(Common::String &drawDataId, Graphics::DrawStep step) {
DrawData id = getDrawDataId(drawDataId);
assert(_widgets[id] != 0);
@@ -252,8 +252,9 @@ void ThemeRenderer::drawDD(DrawData type, const Common::Rect &r) {
if (isWidgetCached(type, r)) {
drawCached(type, r);
} else if (_widgets[type] != 0) {
- for (uint i = 0; i < _widgets[type]->_steps.size(); ++i)
- _vectorRenderer->drawStep(r, *_widgets[type]->_steps[i]);
+ for (Common::List<Graphics::DrawStep>::const_iterator step = _widgets[type]->_steps.begin();
+ step != _widgets[type]->_steps.end(); ++step)
+ _vectorRenderer->drawStep(r, *step);
}
}
@@ -316,8 +317,7 @@ void ThemeRenderer::drawScrollbar(const Common::Rect &r, int sliderY, int slider
}
void ThemeRenderer::updateScreen() {
-// renderDirtyScreen();
- _vectorRenderer->copyWholeFrame(_system);
+ renderDirtyScreen();
}
void ThemeRenderer::renderDirtyScreen() {
@@ -329,7 +329,6 @@ void ThemeRenderer::renderDirtyScreen() {
for (uint i = 0; i < _dirtyScreen.size(); ++i)
_vectorRenderer->copyFrame(_system, _dirtyScreen[i]);
-// _system->updateScreen();
_dirtyScreen.clear();
}
diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h
index 3ce17c25b0..56b81b21fc 100644
--- a/gui/ThemeRenderer.h
+++ b/gui/ThemeRenderer.h
@@ -42,16 +42,13 @@ namespace GUI {
struct WidgetDrawData;
struct WidgetDrawData {
- Common::Array<Graphics::DrawStep*> _steps;
+ Common::List<Graphics::DrawStep> _steps;
bool _cached;
Graphics::Surface *_surfaceCache;
uint32 _cachedW, _cachedH;
~WidgetDrawData() {
- for (uint i = 0; i < _steps.size(); ++i)
- delete _steps[i];
-
_steps.clear();
if (_surfaceCache) {
@@ -69,8 +66,11 @@ class ThemeRenderer : public Theme {
friend class GUI::Dialog;
friend class GUI::GuiObject;
+ /** Strings representing each value in the DrawData enum */
static const char *kDrawDataStrings[];
- static const int kMaxDialogDepth = 4;
+
+ /** Constant value to expand dirty rectangles, to make sure they are fully copied */
+ static const int kDirtyRectangleThreshold = 2;
public:
enum GraphicsMode {
@@ -159,6 +159,7 @@ public:
void drawChar(const Common::Rect &r, byte ch, const Graphics::Font *font, WidgetStateInfo state) {}
bool addDirtyRect(Common::Rect r, bool backup = false, bool special = false) {
+ r.grow(kDirtyRectangleThreshold);
_dirtyScreen.push_back(r);
return true;
}
@@ -172,7 +173,7 @@ public:
return (DrawData)-1;
}
- void addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step);
+ void addDrawStep(Common::String &drawDataId, Graphics::DrawStep step);
bool addDrawData(DrawData data_id, bool cached);
ThemeParser *parser() {
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index efa7a910e2..4d0b3905b9 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -242,7 +242,7 @@ void NewGui::runLoop() {
while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
if (_needRedraw) {
redraw();
-// _needRedraw = false;
+ _needRedraw = false;
}
// Don't "tickle" the dialog until the theme has had a chance