mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix crash in sprite view for partially out-of-bounds sprites (fixes #2165)
This commit is contained in:
parent
cce8ab2cd1
commit
d990f9bdb7
1
CHANGES
1
CHANGES
|
@ -14,6 +14,7 @@ Other fixes:
|
|||
- GBA: Fix out of bounds ROM accesses on patched ROMs smaller than 32 MiB
|
||||
- Qt: Fix infrequent deadlock when using sync to video
|
||||
- Qt: Fix applying savetype-only overrides
|
||||
- Qt: Fix crash in sprite view for partially out-of-bounds sprites (fixes mgba.io/i/2165)
|
||||
- Util: Fix loading UPS patches that affect the last byte of the file
|
||||
Misc:
|
||||
- Core: Suspend runloop when a core crashes
|
||||
|
|
|
@ -131,16 +131,20 @@ void ObjView::updateTilesGBA(bool force) {
|
|||
m_objInfo = newInfo;
|
||||
m_tileOffset = newInfo.tile;
|
||||
mTileCache* tileCache = mTileCacheSetGetPointer(&m_cacheSet->tiles, newInfo.paletteSet);
|
||||
|
||||
unsigned maxTiles = mTileCacheSystemInfoGetMaxTiles(tileCache->sysConfig);
|
||||
int i = 0;
|
||||
for (unsigned y = 0; y < newInfo.height; ++y) {
|
||||
for (unsigned x = 0; x < newInfo.width; ++x, ++i, ++tile, ++tileBase) {
|
||||
if (tile < maxTiles) {
|
||||
const color_t* data = mTileCacheGetTileIfDirty(tileCache, &m_tileStatus[16 * tileBase], tile, newInfo.paletteId);
|
||||
if (data) {
|
||||
m_ui.tiles->setTile(i, data);
|
||||
} else if (force) {
|
||||
m_ui.tiles->setTile(i, mTileCacheGetTile(tileCache, tile, newInfo.paletteId));
|
||||
}
|
||||
} else {
|
||||
m_ui.tiles->clearTile(i);
|
||||
}
|
||||
}
|
||||
tile += newInfo.stride - newInfo.width;
|
||||
tileBase += newInfo.stride - newInfo.width;
|
||||
|
|
|
@ -44,6 +44,16 @@ void TilePainter::mousePressEvent(QMouseEvent* event) {
|
|||
emit indexPressed(y * (width() / m_size) + x);
|
||||
}
|
||||
|
||||
void TilePainter::clearTile(int index) {
|
||||
QPainter painter(&m_backing);
|
||||
int w = width() / m_size;
|
||||
int x = index % w;
|
||||
int y = index / w;
|
||||
QRect r(x * m_size, y * m_size, m_size, m_size);
|
||||
painter.eraseRect(r);
|
||||
update(r);
|
||||
}
|
||||
|
||||
void TilePainter::setTile(int index, const color_t* data) {
|
||||
QPainter painter(&m_backing);
|
||||
int w = width() / m_size;
|
||||
|
|
|
@ -22,6 +22,7 @@ public:
|
|||
QPixmap backing() const { return m_backing; }
|
||||
|
||||
public slots:
|
||||
void clearTile(int index);
|
||||
void setTile(int index, const color_t*);
|
||||
void setTileCount(int tiles);
|
||||
void setTileMagnification(int mag);
|
||||
|
|
Loading…
Reference in New Issue