diff options
author | Nicola Mettifogo | 2007-03-10 21:23:22 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-03-10 21:23:22 +0000 |
commit | c80c3e3b3bb3f8ffcb03f1d355928aaca254465e (patch) | |
tree | 3d8b5a276e22d0a5c5aa928e9d54225384ca2124 /engines | |
parent | 344e9ba5a811620b3da80a5cb58ee0f14827643b (diff) | |
download | scummvm-rg350-c80c3e3b3bb3f8ffcb03f1d355928aaca254465e.tar.gz scummvm-rg350-c80c3e3b3bb3f8ffcb03f1d355928aaca254465e.tar.bz2 scummvm-rg350-c80c3e3b3bb3f8ffcb03f1d355928aaca254465e.zip |
more robust font management
svn-id: r26068
Diffstat (limited to 'engines')
-rw-r--r-- | engines/parallaction/graphics.cpp | 19 | ||||
-rw-r--r-- | engines/parallaction/graphics.h | 2 |
2 files changed, 14 insertions, 7 deletions
diff --git a/engines/parallaction/graphics.cpp b/engines/parallaction/graphics.cpp index 775035e78a..0596fe9321 100644 --- a/engines/parallaction/graphics.cpp +++ b/engines/parallaction/graphics.cpp @@ -56,7 +56,6 @@ const byte _glyphWidths[126] = { 0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x05, 0x05, 0x05, 0x05 }; -Cnv Graphics::_font; bool Graphics::_proportionalFont = false; Point Graphics::_labelPosition[2] = { { 0, 0 }, { 0, 0 } }; StaticCnv Graphics::_mouseComposedArrow; @@ -797,9 +796,7 @@ void Graphics::getStringExtent(char *text, uint16 maxwidth, int16* width, int16* void Graphics::setFont(const char* name) { - if (_font._array != NULL) - freeCnv(&_font); - + freeCnv(&_font); _vm->_disk->loadFont(name, &_font); } @@ -922,11 +919,20 @@ void Graphics::freeCnv(Cnv *cnv) { // printf("Graphics::freeCnv()\n"); if (!cnv) return; + if (cnv->_count == 0) return; + if (!cnv->_array) return; for (uint16 _si = 0; _si < cnv->_count; _si++) { - free(cnv->_array[_si]); + if (cnv->_array[_si]) { + free(cnv->_array[_si]); + } + cnv->_array[_si] = NULL; } - if (cnv->_array) free(cnv->_array); + + if (cnv->_array) + free(cnv->_array); + + cnv->_count = 0; cnv->_array = NULL; return; @@ -1126,6 +1132,7 @@ Graphics::Graphics(Parallaction* vm) : initMouse( 0 ); + _font._count = 0; _font._array = NULL; return; diff --git a/engines/parallaction/graphics.h b/engines/parallaction/graphics.h index 5aef2138ea..f338c91ccf 100644 --- a/engines/parallaction/graphics.h +++ b/engines/parallaction/graphics.h @@ -156,7 +156,7 @@ protected: static byte _mouseArrow[256]; static StaticCnv _mouseComposedArrow; - static Cnv _font; + Cnv _font; protected: |