View Single Post
Old 05-08-2018, 07:51 AM   #405
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,746
Karma: 24032915
Join Date: Dec 2010
Device: Kindle PW2
Plugin Runner windows-only crash issue

I'm working on a Windows-only plugin that'll crash Sigil, if the click Plugin Runner window close button (X) is clicked while the plugin is running. (On my Linux machine, Sigil displays: Error Parsing Result XML: Encountered incorrectly encoded content., but it doesn't crash.)

Steps to reproduce this issue:

1. Install and run the crash plugin.
2. Click the first option in the list box.
3. Click the Plugin Runner window close button (X).

The plugin uses the following code:
Spoiler:

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from tkinter import Tk,  Listbox
       
def run(bk):

    # list box helper function
    def get_list(event):
        index = Lb1.curselection()[0]
        selected_option = Lb1.get(index)
        print('You selected:', selected_option, '\n')

    # define list box
    options = ['option 1', 'option 2', 'option 3']
    root = Tk()
    Lb1 = Listbox(root)
    Lb1.config(width=0, height=0)
    Lb1.bind('<ButtonRelease-1>', get_list)
    
    # populate list box
    position = 0
    for option in options:
        position += 1
        Lb1.insert(position, option)
    Lb1.pack()
    root.mainloop()

    return 0
        
def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())


How do I need to change the code to gracefully exit the plugin, if the Plugin Runner window is closed?
Attached Files
File Type: zip crash.zip (1.0 KB, 783 views)
Doitsu is offline   Reply With Quote