Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read Access Violation
#13
(10-29-2022, 07:44 PM)megamarc Wrote: Hi! Thanks for your suggestion.
However, it's not recommended to modify linked resources that have been loaded recursively. For example when you load a tileset or a bitmap, a palette is also loaded/created as a child reference, and the parent resource "owns" the palette, When you destroy the tileset or bitmap, its palette is also destroyed. If not, there would be a memory leak. If you change the palette of a bitmap or tileset, and then destroy the parent resource, the engine will destroy the wrong palette and leave the original palette "orphaned" and leaked. That's why is not a good idea to modify their palettes, instead, set the layer palette with TLN_SetLayerPalette()
This alwo happens with tilesets that are loaded and owned by a particular tilemap.

Effectively, I wrote this code :
Code:
bool TLN_SetTilesetPalette(TLN_Tileset tileset, TLN_Palette palette)
{
if (CheckBaseObject(tileset, OT_TILESET) && palette != NULL)
{
TLN_SetLastError(TLN_ERR_OK);
tileset->palette = palette;
return true;
}
else
return false;
}

and the old palette isn't cleaned up.
Can TLN_SetLayerPalette() deal with tilesets palettes? It wasn't a problem when you had only one tileset per layer to deal with, so only one palette. But now you can have up to 8 tilesets per layer, so up to 8 palettes to deal with.
Reply


Messages In This Thread
Read Access Violation - by Midnight Syntax - 10-24-2022, 02:42 AM
RE: Read Access Violation - by megamarc - 10-25-2022, 05:18 AM
RE: Read Access Violation - by Midnight Syntax - 10-25-2022, 07:59 AM
RE: Read Access Violation - by Daniel H. - 10-25-2022, 04:49 PM
RE: Read Access Violation - by megamarc - 10-26-2022, 12:35 AM
RE: Read Access Violation - by Midnight Syntax - 10-26-2022, 09:05 AM
RE: Read Access Violation - by Daniel H. - 10-27-2022, 01:02 AM
RE: Read Access Violation - by megamarc - 10-27-2022, 03:15 AM
RE: Read Access Violation - by System64 - 10-27-2022, 03:47 AM
RE: Read Access Violation - by megamarc - 10-27-2022, 09:24 AM
RE: Read Access Violation - by System64 - 10-27-2022, 11:45 PM
RE: Read Access Violation - by megamarc - 10-29-2022, 07:44 PM
RE: Read Access Violation - by System64 - 10-29-2022, 10:30 PM
RE: Read Access Violation - by megamarc - 10-30-2022, 02:34 AM
RE: Read Access Violation - by System64 - 10-30-2022, 02:51 AM
RE: Read Access Violation - by megamarc - 10-30-2022, 04:10 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)