Pythonista-Issues
Pythonista-Issues copied to clipboard
Form Dialog unstable in v3.4
trafficstars
The form dialog is very unstable often resulting in segmentation faults. It seems to happen mostly with forms with many fields where scrolling is required to make rows visible.
Adding these 2 lines to the form_dialog function reduces failures, but not 100%.
c.container_view.present('sheet')
c.container_view.wait_modal()
# fix crash with these 2 lines
c.cells.clear()
c.view.reload_data()
This sample script will crash under the following conditions:
- set try_fix = False
- run script
- scroll to RATING section, select 3, click Done or
- scroll until RATING section is a the top of the view. Larger phone may require more scrolling.
- rerun script
It will usually crash when run the 2nd or 3rd time.
import sys, os, shutil, time, pprint
import dialogs
try_fix = False
"""
Dupicate issue:
set try_fix = False
run script
scroll to RATING section, select 3, click Done
or
scroll until RATING section is a the top of the view.
(larger phone may require more scrolling.
rerun script
It will usually crash when run the 2nd or 3rd time.
"""
sections = [('Special Filters',
[{'key': 'limit', 'title': 'Artist Limit (0 for None):',
'type': 'number', 'value': '30'},
{'key': 'country_count', 'title': 'Country Count: ', 'type': 'check'},
{'key': 'best_artists', 'title': 'Best Artists: ', 'type': 'check'},
{'key': 'best_albums', 'title': 'Best Albums: ', 'type': 'check'},
{'key': 'best_genres', 'title': 'Best Genres: ', 'type': 'check'},
{'key': 'best_years', 'title': 'Best Years: ', 'type': 'check'},
{'key': 'best_decades', 'title': 'Best Decades: ', 'type': 'check'},
{'key': 'one_hit_wonders', 'title': 'One Hit Wonders: ', 'type': 'check'} ]),
('Year Range',
[{'key': 'year_from', 'title': 'Year From:', 'type': 'number', 'value': '1990'},
{'key': 'year_to', 'title': 'Year To: ', 'type': 'number', 'value': '2022'},
{'key': 'one_song', 'title': 'One Song: ', 'type': 'check', 'value': False},
{'key': 'missing_song_info', 'title': 'Missing Song Info:',
'type': 'check', 'value': False},
{'key': 'song_info', 'title': 'Song Info:', 'type': 'check', 'value': False},
{'key': 'sub_and', 'title': 'Subgenre AND:', 'type': 'check', 'value': False},
{'key': 'xmas', 'title': 'Include Xmas Songs?', 'type': 'check', 'value': False},
{'key': 'pos_from', 'title': 'Pos From: ', 'type': 'number', 'value': ''},
{'key': 'pos_to', 'title': 'Pos To:', 'type': 'number', 'value': ''},
{'key': 'missing_pos', 'title': 'Missing Pos:', 'type': 'check', 'value': False},
{'key': 'us_pos_from', 'title': 'US Pos From: ', 'type': 'number', 'value': ''},
{'key': 'us_pos_to', 'title': 'US Pos To:', 'type': 'number', 'value': ''}]),
('Rating',
[{'title': '3', 'type': 'check'},
{'title': '4', 'type': 'check'},
{'title': '5', 'type': 'check'}]),
('Speed',
[{'title': 'S5', 'type': 'check'},
{'title': 'S4', 'type': 'check'},
{'title': 'S3', 'type': 'check'},
{'title': 'S2', 'type': 'check'},
{'title': 'S1', 'type': 'check'},
{'title': 'Missing', 'type': 'check'}]),
('Popularity',
[{'title': '[10]', 'type': 'check'},
{'title': '[9]', 'type': 'check'},
{'title': '[8]', 'type': 'check'},
{'title': '[7]', 'type': 'check'},
{'title': '[6]', 'type': 'check'},
{'title': '[5]', 'type': 'check'},
{'title': '[4]', 'type': 'check'},
{'title': '[3]', 'type': 'check'},
{'title': '[2]', 'type': 'check'},
{'title': '[1]', 'type': 'check'},
{'title': '[0]', 'type': 'check'}]),
('Charts',
[{'title': '50s', 'type': 'check'},
{'title': '60s', 'type': 'check'},
{'title': '70s', 'type': 'check'},
{'title': '80s', 'type': 'check'},
{'title': '90s', 'type': 'check'},
{'title': '2000s', 'type': 'check'},
{'title': '2010s', 'type': 'check'},
{'title': '2020s', 'type': 'check'}]),
('Genres',
[{'title': 'Rock', 'type': 'check'},
{'title': 'Pop', 'type': 'check'},
{'title': 'Indie', 'type': 'check'},
{'title': 'Rap', 'type': 'check'},
{'title': 'Thrash', 'type': 'check'},
{'title': 'Country', 'type': 'check'},
{'title': 'Dance', 'type': 'check'},
{'title': 'Disco', 'type': 'check'},
{'title': 'Soul', 'type': 'check'},
{'title': 'Post-punk', 'type': 'check'},
{'title': 'Punk', 'type': 'check'}]),
('Sub Genres',
[{'title': 'Aor', 'type': 'check'},
{'title': 'Modernindie', 'type': 'check'},
{'title': 'Modernrock', 'type': 'check'},
{'title': 'Summer', 'type': 'check'},
{'title': 'Classicrock', 'type': 'check'},
{'title': 'Northernsoul', 'type': 'check'},
{'title': 'Indierock', 'type': 'check'},
{'title': 'Drumnbass', 'type': 'check'},
{'title': 'Funk', 'type': 'check'},
{'title': 'Hairmetal', 'type': 'check'},
{'title': 'Blues', 'type': 'check'},
{'title': 'Reggae', 'type': 'check'},
{'title': 'Breakdance', 'type': 'check'},
{'title': 'Garage', 'type': 'check'},
{'title': 'Heavymetal', 'type': 'check'},
{'title': 'House', 'type': 'check'},
{'title': 'Cheese', 'type': 'check'},
{'title': 'Billy', 'type': 'check'},
{'title': 'Grime', 'type': 'check'},
{'title': 'Rare', 'type': 'check'},
{'title': 'Yachtrock', 'type': 'check'},
{'title': 'Synthpop', 'type': 'check'}]),
('Occasions',
[{'title': 'Christmas', 'type': 'check'},
{'title': 'Bonfire', 'type': 'check'},
{'title': 'Halloween', 'type': 'check'},
{'title': 'Birthday', 'type': 'check'}]),
('Tempo',
[{'title': 'Slow', 'type': 'check'},
{'title': 'Normal', 'type': 'check'},
{'title': 'Fast', 'type': 'check'},
{'title': 'Not slow', 'type': 'check'}])]
filepath = os.path.join(os.path.dirname(sys.executable),
'Frameworks/Py3Kit.framework/pylib/site-packages/pythonista/dialogs.py')
#print(filepath)
##shutil.copy2(filepath, '.')
def display(playlist_filter):
if try_fix:
print('form dialog fix')
def form_dialog(title='', fields=None, sections=None, done_button_title='Done'):
c = dialogs._FormDialogController(title, sections, done_button_title=done_button_title)
c.container_view.present('sheet')
c.container_view.wait_modal()
c.cells.clear() # fix
c.view.reload_data() # crash
# Get rid of the view to avoid a retain cycle:
c.container_view = None
if c.was_canceled:
return None
return c.values
diag = form_dialog(title = 'Song Filter', sections=sections)
else:
print('form dialog standard')
diag = dialogs.form_dialog(title = 'Song Filter', sections=sections)
print('done')
time.sleep(1)
return diag
if __name__ == '__main__':
result = display(None)
if result:
print(result['year_to'])