@@ -796,7 +796,7 @@ def qc_show_hpcf_history(sender=None, app_data=None):
796796 hpcf_database_sel = dpg .get_value ('qc_hpcf_active_database' )
797797
798798
799- #toggled on and there are saved filters
799+ #toggled on and there are saved filters -> populate lists with saved filters
800800 if headphone_list_saved and headphone_list_saved != None and app_data == True :
801801 #if selected headphone is in history, set default to selected, otherwise pick first value
802802 default_headphone = headphone_selected if headphone_selected in headphone_list_saved else headphone_list_saved [0 ]
@@ -828,7 +828,16 @@ def qc_show_hpcf_history(sender=None, app_data=None):
828828 #reset sample list to Sample A
829829 dpg .set_value ("qc_hpcf_sample" , sample_new )
830830
831+ #toggled off -> populate list with previously applied filters
831832 else :
833+ #validate lists in case of misalignment between applied filter and current DB, will reset
834+ brands_list , brand_selected = hf .ensure_valid_selection ( brands_list , brand_selected )
835+ hp_list_selected = hpcf_functions .get_headphone_list (conn , brand_selected )#
836+ hp_list_selected , headphone_selected = hf .ensure_valid_selection (hp_list_selected , headphone_selected )
837+ sample_list_specific = hpcf_functions .get_samples_list (conn , headphone_selected )
838+ sample_list_sorted = (sorted (sample_list_specific ))
839+ sample_list_sorted , sample_selected = hf .ensure_valid_selection (sample_list_sorted , sample_selected )
840+
832841 #reset brand list
833842 dpg .configure_item ('qc_hpcf_brand' ,items = brands_list )
834843 #reset brand value to first brand
@@ -838,8 +847,7 @@ def qc_show_hpcf_history(sender=None, app_data=None):
838847 dpg .configure_item ('qc_hpcf_headphone' ,items = hp_list_selected )
839848 dpg .set_value ("qc_hpcf_headphone" , headphone_selected )
840849 #also update sample list
841- sample_list_specific = hpcf_functions .get_samples_list (conn , headphone_selected )
842- sample_list_sorted = (sorted (sample_list_specific ))
850+
843851 dpg .configure_item ('qc_hpcf_sample' ,items = sample_list_sorted )
844852 #also update plot
845853 hpcf_functions .hpcf_to_plot (conn , headphone_selected , sample_selected , plot_type = 2 )
0 commit comments