Commit 617dbd01 authored by Jeffrey Lee's avatar Jeffrey Lee

Fix unreliable sorting of sprites

Detail:
  c/Menus - Fix sprite sort code to take into account the fact that variable-length array allocations may cause flex blocks to be moved (due to CLib allocating the array from the heap)
Admin:
  Tested on Raspberry Pi
  Appears to fix 'sort by name' sometimes resulting in a random sort order being used
  Will hopefully fix 'out of memory' error reported on forums (unable to reproduce here, but this is a likely cause)
  https://www.riscosopen.org/forum/forums/4/topics/3657


Version 2.20. Tagged as 'Paint-2_20'
parent 2e0c3993
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.19"
Module_Version SETA 219
Module_MajorVersion SETS "2.20"
Module_Version SETA 220
Module_MinorVersion SETS ""
Module_Date SETS "26 Sep 2015"
Module_ApplicationDate SETS "26-Sep-15"
Module_Date SETS "14 Oct 2015"
Module_ApplicationDate SETS "14-Oct-15"
Module_ComponentName SETS "Paint"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Paint"
Module_FullVersion SETS "2.19"
Module_HelpVersion SETS "2.19 (26 Sep 2015)"
Module_FullVersion SETS "2.20"
Module_HelpVersion SETS "2.20 (14 Oct 2015)"
END
/* (2.19)
/* (2.20)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.19
#define Module_MajorVersion_CMHG 2.20
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 26 Sep 2015
#define Module_Date_CMHG 14 Oct 2015
#define Module_MajorVersion "2.19"
#define Module_Version 219
#define Module_MajorVersion "2.20"
#define Module_Version 220
#define Module_MinorVersion ""
#define Module_Date "26 Sep 2015"
#define Module_Date "14 Oct 2015"
#define Module_ApplicationDate "26-Sep-15"
#define Module_ApplicationDate "14-Oct-15"
#define Module_ComponentName "Paint"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Paint"
#define Module_FullVersion "2.19"
#define Module_HelpVersion "2.19 (26 Sep 2015)"
#define Module_LibraryVersionInfo "2:19"
#define Module_FullVersion "2.20"
#define Module_HelpVersion "2.20 (14 Oct 2015)"
#define Module_LibraryVersionInfo "2:20"
......@@ -2431,18 +2431,26 @@ void menus_file_handler (void *handle, char *hit)
case m_Misc_SBSize:
{ /* Sort by name or size */
sprite_area *unsorted = window->data->file.spritearea;
int count = unsorted->number;
if (count < 2) break; /* Not worth sorting */
sprite_tosort tosort[count];
sprite_tosort *tosortptr[count];
/* variable length array allocation may have caused flex blocks to move - re-fetch sprite area pointer */
tosort[0].orgsprite = NULL; /* Paranoia - try and ensure compiler doesn't postpone array allocation */
tosortptr[0] = NULL;
unsorted = window->data->file.spritearea;
sprite_area *sorted;
sprite_header *header;
int count = unsorted->number;
main_file *file = &window->data->file;
main_sprite *sprite;
int loop, next;
BOOL byname = (hit[1] == m_Misc_SBName);
sprite_tosort tosort[count];
sprite_tosort *tosortptr[count];
os_regset regs;
if (count < 2) break; /* Not worth sorting */
ftracef1 ("sort - sorting %d sprites\n", count);
count = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment