[Scummvm-git-logs] scummvm branch-2-7 -> 93190f047b616f590ad6bdac9f04aabf3c59cb24
ccawley2011
noreply at scummvm.org
Sun Feb 5 22:27:11 UTC 2023
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0af9e4b53b COMMON: Simplify API for getHumanReadableBytes()
50d7086d4a TINYGL: Fix memory leak
93190f047b STARK: Fix memory leak
Commit: 0af9e4b53b7ed11a27d8ec22f1ab8c57f41c6101
https://github.com/scummvm/scummvm/commit/0af9e4b53b7ed11a27d8ec22f1ab8c57f41c6101
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-05T22:26:18Z
Commit Message:
COMMON: Simplify API for getHumanReadableBytes()
Changed paths:
common/util.cpp
common/util.h
gui/downloaddialog.cpp
gui/downloadpacksdialog.cpp
gui/options.cpp
gui/saveload-dialog.cpp
diff --git a/common/util.cpp b/common/util.cpp
index 9a2b99d4ec7..4540f3bad33 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -177,33 +177,33 @@ bool isBlank(int c) {
#pragma mark -
-Common::U32String getHumanReadableBytes(uint64 bytes, Common::String &unitsOut) {
+Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut) {
if (bytes < 1024) {
// I18N: Abbreviation for 'bytes' as data size
- unitsOut = _("B");
+ unitsOut = _s("B");
return Common::String::format("%lu", (unsigned long int)bytes);
}
double floating = bytes / 1024.0;
- // I18N: Abbreviation for 'kilobytes' as data size
- unitsOut = _("KB");
+ // I18N: Abbreviation for 'kilobytes' as data size
+ unitsOut = _s("KB");
if (floating >= 1024) {
floating /= 1024.0;
// I18N: Abbreviation for 'megabytes' as data size
- unitsOut = _("MB");
+ unitsOut = _s("MB");
}
if (floating >= 1024) {
floating /= 1024.0;
// I18N: Abbreviation for 'gigabytes' as data size
- unitsOut = _("GB");
+ unitsOut = _s("GB");
}
if (floating >= 1024) { // woah
floating /= 1024.0;
// I18N: Abbreviation for 'terabytes' as data size
- unitsOut = _("TB");
+ unitsOut = _s("TB");
}
// print one digit after floating point
diff --git a/common/util.h b/common/util.h
index 60f606a4be0..b4d9be28c70 100644
--- a/common/util.h
+++ b/common/util.h
@@ -413,7 +413,7 @@ bool isBlank(int c);
*
* @return String with a floating point number representing the given size.
*/
-Common::U32String getHumanReadableBytes(uint64 bytes, Common::String &unitsOut);
+Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut);
/** @} */
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index 0a037865066..3eba17dcea7 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -208,17 +208,16 @@ void DownloadDialog::reflowLayout() {
}
Common::U32String DownloadDialog::getSizeLabelText() {
- Common::String downloaded, downloadedUnits, total, totalUnits;
- downloaded = getHumanReadableBytes(CloudMan.getDownloadBytesNumber(), downloadedUnits);
- total = getHumanReadableBytes(CloudMan.getDownloadTotalBytesNumber(), totalUnits);
+ const char *downloadedUnits, *totalUnits;
+ Common::String downloaded = Common::getHumanReadableBytes(CloudMan.getDownloadBytesNumber(), downloadedUnits);
+ Common::String total = Common::getHumanReadableBytes(CloudMan.getDownloadTotalBytesNumber(), totalUnits);
return Common::U32String::format(_("Downloaded %s %S / %s %S"), downloaded.c_str(), _(downloadedUnits).c_str(), total.c_str(), _(totalUnits).c_str());
}
Common::U32String DownloadDialog::getSpeedLabelText() {
- Common::String speed, speedUnits;
- speed = getHumanReadableBytes(CloudMan.getDownloadSpeed(), speedUnits);
- speedUnits += "/s";
- return Common::U32String::format(_("Download speed: %s %S"), speed.c_str(), _(speedUnits).c_str());
+ const char *speedUnits;
+ Common::String speed = Common::getHumanReadableBytes(CloudMan.getDownloadSpeed(), speedUnits);
+ return Common::U32String::format(_("Download speed: %s %S/s"), speed.c_str(), _(speedUnits).c_str());
}
void DownloadDialog::refreshWidgets() {
diff --git a/gui/downloadpacksdialog.cpp b/gui/downloadpacksdialog.cpp
index a990cec0bee..412116d3c4c 100644
--- a/gui/downloadpacksdialog.cpp
+++ b/gui/downloadpacksdialog.cpp
@@ -255,8 +255,8 @@ void DownloadPacksDialog::setState(IconProcessState state) {
break;
case kDownloadStateListCalculated: {
- Common::String size, sizeUnits;
- size = getHumanReadableBytes(g_state->totalSize, sizeUnits);
+ const char *sizeUnits;
+ Common::String size = Common::getHumanReadableBytes(g_state->totalSize, sizeUnits);
_statusText->setLabel(Common::U32String::format(_("Detected %d new packs, %s %S"), g_state->fileHash.size(), size.c_str(), _(sizeUnits).c_str()));
@@ -282,8 +282,8 @@ void DownloadPacksDialog::setState(IconProcessState state) {
break;
case kDownloadComplete: {
- Common::String size, sizeUnits;
- size = getHumanReadableBytes(g_state->totalSize, sizeUnits);
+ const char *sizeUnits;
+ Common::String size = Common::getHumanReadableBytes(g_state->totalSize, sizeUnits);
_statusText->setLabel(Common::U32String::format(_("Download complete, downloaded %d packs, %s %S"), g_state->totalFiles, size.c_str(), _(sizeUnits).c_str()));
_cancelButton->setVisible(false);
_cancelButton->setLabel(_("Cancel download"));
@@ -358,17 +358,16 @@ void DownloadPacksDialog::reflowLayout() {
}
Common::U32String DownloadPacksDialog::getSizeLabelText() {
- Common::String downloaded, downloadedUnits, total, totalUnits;
- downloaded = getHumanReadableBytes(g_state->downloadedSize, downloadedUnits);
- total = getHumanReadableBytes(g_state->totalSize, totalUnits);
+ const char *downloadedUnits, *totalUnits;
+ Common::String downloaded = Common::getHumanReadableBytes(g_state->downloadedSize, downloadedUnits);
+ Common::String total = Common::getHumanReadableBytes(g_state->totalSize, totalUnits);
return Common::U32String::format(_("Downloaded %s %S / %s %S"), downloaded.c_str(), _(downloadedUnits).c_str(), total.c_str(), _(totalUnits).c_str());
}
Common::U32String DownloadPacksDialog::getSpeedLabelText() {
- Common::String speed, speedUnits;
- speed = getHumanReadableBytes(getDownloadSpeed(), speedUnits);
- speedUnits += "/s";
- return Common::U32String::format(_("Download speed: %s %S"), speed.c_str(), _(speedUnits).c_str());
+ const char *speedUnits;
+ Common::String speed = Common::getHumanReadableBytes(getDownloadSpeed(), speedUnits);
+ return Common::U32String::format(_("Download speed: %s %S/s"), speed.c_str(), _(speedUnits).c_str());
}
void DownloadPacksDialog::refreshWidgets() {
@@ -457,10 +456,10 @@ void DownloadPacksDialog::clearCache() {
totalSize += size;
}
- Common::String sizeUnits;
- Common::String size = getHumanReadableBytes(totalSize, sizeUnits);
+ const char *sizeUnits;
+ Common::String size = Common::getHumanReadableBytes(totalSize, sizeUnits);
- GUI::MessageDialog dialog(Common::U32String::format(_("You are about to remove %s %s of data, deleting all previously downloaded %S. Do you want to proceed?"), size.c_str(), sizeUnits.c_str(), _packname.c_str()), _("Proceed"), _("Cancel"));
+ GUI::MessageDialog dialog(Common::U32String::format(_("You are about to remove %s %S of data, deleting all previously downloaded %S. Do you want to proceed?"), size.c_str(), _(sizeUnits).c_str(), _packname.c_str()), _("Proceed"), _("Cancel"));
if (dialog.runModal() == ::GUI::kMessageOK) {
// Build list of previously downloaded icon files
diff --git a/gui/options.cpp b/gui/options.cpp
index bb06f9f7a59..081cfdf7f3d 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -3566,8 +3566,8 @@ void GlobalOptionsDialog::setupCloudTab() {
if (_storageUsedSpaceDesc) _storageUsedSpaceDesc->setVisible(shownConnectedInfo);
if (_storageUsedSpace) {
uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex);
- Common::String usedSpaceNumber, usedSpaceUnits;
- usedSpaceNumber = Common::getHumanReadableBytes(usedSpace, usedSpaceUnits);
+ const char *usedSpaceUnits;
+ Common::String usedSpaceNumber = Common::getHumanReadableBytes(usedSpace, usedSpaceUnits);
_storageUsedSpace->setLabel(Common::U32String::format("%s %S", usedSpaceNumber.c_str(), _(usedSpaceUnits).c_str()));
_storageUsedSpace->setVisible(shownConnectedInfo);
}
diff --git a/gui/saveload-dialog.cpp b/gui/saveload-dialog.cpp
index bc7f75d44bb..becf92617c5 100644
--- a/gui/saveload-dialog.cpp
+++ b/gui/saveload-dialog.cpp
@@ -113,9 +113,9 @@ void SaveLoadCloudSyncProgressDialog::pollCloudMan() {
Cloud::Storage::SyncDownloadingInfo info;
CloudMan.getSyncDownloadingInfo(info);
- Common::String downloaded, downloadedUnits, total, totalUnits;
- downloaded = getHumanReadableBytes(info.bytesDownloaded, downloadedUnits);
- total = getHumanReadableBytes(info.bytesToDownload, totalUnits);
+ const char *downloadedUnits, *totalUnits;
+ Common::String downloaded = Common::getHumanReadableBytes(info.bytesDownloaded, downloadedUnits);
+ Common::String total = Common::getHumanReadableBytes(info.bytesToDownload, totalUnits);
Common::String progressPercent = Common::String::format("%u %%", progress);
Common::String filesDownloaded = Common::String::format("%llu", (unsigned long long)info.filesDownloaded);
Commit: 50d7086d4ace33b852dfa4e14b4f9b212487aeec
https://github.com/scummvm/scummvm/commit/50d7086d4ace33b852dfa4e14b4f9b212487aeec
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-05T22:26:33Z
Commit Message:
TINYGL: Fix memory leak
Changed paths:
engines/freescape/gfx_tinygl_texture.cpp
engines/freescape/gfx_tinygl_texture.h
graphics/tinygl/init.cpp
graphics/tinygl/texture.cpp
graphics/tinygl/zgl.h
diff --git a/engines/freescape/gfx_tinygl_texture.cpp b/engines/freescape/gfx_tinygl_texture.cpp
index f843d34d5a6..887a386afb7 100644
--- a/engines/freescape/gfx_tinygl_texture.cpp
+++ b/engines/freescape/gfx_tinygl_texture.cpp
@@ -33,7 +33,6 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
_width = surface->w;
_height = surface->h;
_format = surface->format;
- _id = 0;
_internalFormat = 0;
_sourceFormat = 0;
@@ -43,7 +42,6 @@ TinyGLTexture::TinyGLTexture(const Graphics::Surface *surface) {
}
TinyGLTexture::~TinyGLTexture() {
- tglDeleteTextures(1, &_id);
tglDeleteBlitImage(_blitImage);
}
diff --git a/engines/freescape/gfx_tinygl_texture.h b/engines/freescape/gfx_tinygl_texture.h
index cb87a3552bc..5dbedf40f8d 100644
--- a/engines/freescape/gfx_tinygl_texture.h
+++ b/engines/freescape/gfx_tinygl_texture.h
@@ -40,7 +40,6 @@ public:
void update(const Graphics::Surface *surface) override;
void updatePartial(const Graphics::Surface *surface, const Common::Rect &rect) override;
- TGLuint _id;
TGLuint _internalFormat;
TGLuint _sourceFormat;
diff --git a/graphics/tinygl/init.cpp b/graphics/tinygl/init.cpp
index f6a5c05a870..dafcb8f5156 100644
--- a/graphics/tinygl/init.cpp
+++ b/graphics/tinygl/init.cpp
@@ -37,15 +37,11 @@ void GLContext::initSharedState() {
GLSharedState *s = &shared_state;
s->lists = (GLList **)gl_zalloc(sizeof(GLList *) * MAX_DISPLAY_LISTS);
s->texture_hash_table = (GLTexture **)gl_zalloc(sizeof(GLTexture *) * TEXTURE_HASH_TABLE_SIZE);
-
- alloc_texture(0);
}
void GLContext::endSharedState() {
GLSharedState *s = &shared_state;
- uint h = 0;
- free_texture(h);
for (int i = 0; i < MAX_DISPLAY_LISTS; i++) {
// TODO
}
@@ -146,7 +142,7 @@ void GLContext::init(int screenW, int screenH, Graphics::PixelFormat pixelFormat
// textures
texture_2d_enabled = false;
- current_texture = alloc_texture(0);
+ current_texture = default_texture = alloc_texture(0);
maxTextureName = 0;
texture_mag_filter = TGL_LINEAR;
texture_min_filter = TGL_NEAREST_MIPMAP_LINEAR;
@@ -291,6 +287,7 @@ void GLContext::deinit() {
specbuf_cleanup();
for (int i = 0; i < 3; i++)
gl_free(matrix_stack[i]);
+ free_texture(default_texture);
endSharedState();
gl_free(vertex);
delete fb;
diff --git a/graphics/tinygl/texture.cpp b/graphics/tinygl/texture.cpp
index aec1fe348d2..79d83e07f6a 100644
--- a/graphics/tinygl/texture.cpp
+++ b/graphics/tinygl/texture.cpp
@@ -45,10 +45,6 @@ GLTexture *GLContext::find_texture(uint h) {
return nullptr;
}
-void GLContext::free_texture(uint h) {
- free_texture(find_texture(h));
-}
-
void GLContext::free_texture(GLTexture *t) {
GLTexture **ht;
GLImage *im;
@@ -281,7 +277,7 @@ void GLContext::gl_DeleteTextures(TGLsizei n, const TGLuint *textures) {
TinyGL::GLTexture *t = find_texture(textures[i]);
if (t) {
if (t == current_texture) {
- current_texture = find_texture(0);
+ current_texture = default_texture;
}
t->disposed = true;
}
diff --git a/graphics/tinygl/zgl.h b/graphics/tinygl/zgl.h
index 753f692370e..e4c2f4d49c8 100644
--- a/graphics/tinygl/zgl.h
+++ b/graphics/tinygl/zgl.h
@@ -294,7 +294,7 @@ struct GLContext {
int current_color_material_type;
// textures
- GLTexture *current_texture;
+ GLTexture *current_texture, *default_texture;
uint maxTextureName;
bool texture_2d_enabled;
int texture_mag_filter;
@@ -477,7 +477,6 @@ public:
GLTexture *alloc_texture(uint h);
GLTexture *find_texture(uint h);
- void free_texture(uint h);
void free_texture(GLTexture *t);
void gl_GenTextures(TGLsizei n, TGLuint *textures);
void gl_DeleteTextures(TGLsizei n, const TGLuint *textures);
Commit: 93190f047b616f590ad6bdac9f04aabf3c59cb24
https://github.com/scummvm/scummvm/commit/93190f047b616f590ad6bdac9f04aabf3c59cb24
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-02-05T22:26:40Z
Commit Message:
STARK: Fix memory leak
Changed paths:
engines/stark/stark.cpp
diff --git a/engines/stark/stark.cpp b/engines/stark/stark.cpp
index b4b561716d3..7ec8476f37b 100644
--- a/engines/stark/stark.cpp
+++ b/engines/stark/stark.cpp
@@ -75,7 +75,6 @@ StarkEngine::~StarkEngine() {
delete StarkServices::instance().dialogPlayer;
delete StarkServices::instance().randomSource;
delete StarkServices::instance().scene;
- delete StarkServices::instance().gfx;
delete StarkServices::instance().staticProvider;
delete StarkServices::instance().resourceProvider;
delete StarkServices::instance().global;
@@ -86,6 +85,7 @@ StarkEngine::~StarkEngine() {
delete StarkServices::instance().settings;
delete StarkServices::instance().gameChapter;
delete StarkServices::instance().gameMessage;
+ delete StarkServices::instance().gfx;
StarkServices::destroy();
More information about the Scummvm-git-logs
mailing list