Author Topic: fe.filters array not refreshing correctly -how to get filter names as variables?  (Read 50 times)

farique

  • Jr. Member
  • **
  • Posts: 20
    • View Profile
Hi.
On my layout I need to get the filters names as strings to work with them. So I am using fe.filters (Magic Tokens do not pass as a variable as far as I know). So far so good.

The problem is: when I move from a display to another (with different emulators, lists and filters) that are using the same layout, the contents of the fe.filters array do not update, it keeps using the filter information of the previous display. If I move to a display using a different layout and back or I use the toggle layout key (refreshing it), the array is filled correctly.

Here is a little layout that shows this happening:

Code: [Select]
function transition_callback( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.FromOldSelection:
case Transition.StartLayout:
case Transition.ToNewList:
print ( "\n"+fe.filters.len()+"\n" )
for (local f=0; f < fe.filters.len(); f++) {
print ( fe.filters[f].name+"\n" )
}
print ( fe.filters[fe.list.filter_index].size+"\n" )
break
}
return false
}
fe.add_transition_callback( "transition_callback" )

And the console output:

Code: [Select]
*** Initializing display: 'Atari 2600'
 - Loaded master romlist 'Atari 2600' in 47 ms (539 entries kept, 0 discarded)
 - Constructed 6 filters in 0 ms (3234 comparisons)

6
All
Favourites
Homebrew
Commercial
Prototype
Adult
539

*** Initializing display: 'Odyssey2'
 - Loaded master romlist 'Odyssey2' in 6 ms (121 entries kept, 0 discarded)
 - Constructed 4 filters in 0 ms (484 comparisons)

6
All
Favourites
Homebrew
Commercial
Prototype
Adult
539

This console output is the result of opening AM on the Atari 2600 display and moving to the Odyssey2 display (both using the same layout). As you can see, AM fills fe.filters with the correct Atari 2600 information but when I move to the Odyssey2 display it finds the correct filters and entries but do not update the fe.filters array.

What am I missing?
Thanks.
« Last Edit: September 13, 2018, 12:11:07 PM by farique »