Description:
In a GRT plugin, if a Form is instantiated and run_modal() is done on it, close() does not close the modal. When the context is dereferenced in python, WB hangs up.
How to repeat:
1. Put the code in mform_bug_minimal_grt.py /usr/local/lib/mysql-workbench/modules/
The ending _grt.py is important. Otherwise the file will not show up in the menu.
The dir path could be different on your OS.
2. run WB and load a model (clicking the new file icon will do). Run WB in a terminal to see the debugging output.
3. Go to the menu plugins->catalog->mforms Minimal Test Case
now a popup should show up.
4. Click OK on the pop-up.
the Workbench GUI should have hung up at this point.
Python Code on Pastebin: http://pastebin.com/m28a01f24
The same code attached:
#
# mform_bug_minimal_grt.py
# MySQLWorkbench
#
# Created by Damian Marcinczyk on 9/Dec/09.
# Copyright (c) 2009 DJM ERT Ltd. All rights reserved.
#
# import the wb module
from wb import *
# import the grt module
import grt
# import the mforms module for GUI stuff
import mforms
# define this Python module as a GRT module
ModuleInfo = DefineModule(name= "PyWbExtraUtils", author= "DJM ERT Ltd", version="1.0")
# @wbexport exports the function from the module and also describes the return and
# argument types of the function
# @wbplugin defines the name of the plugin to "wb.catalog.util.dumpColumns", sets the caption to be
# shown in places like the menu, where to take input arguments from and also that it should be included
# in the Catalog submenu in Plugins.
@ModuleInfo.plugin("wb.catalog.util.mformBugMinimal", caption= "mform Bug Minimal Test Case", input= [wbinputs.currentCatalog()], pluginMenu= "Catalog")
@ModuleInfo.export(grt.INT, grt.classes.db_Catalog)
def mformBugMinimalTestCase(catalog):
form = mforms.Form(None, mforms.FormSingleFrame)
label = mforms.newLabel('testLabel')
label.set_wrap_text(True)
ok = mforms.newButton()
ok.set_text('OK')
cancel = mforms.newButton()
cancel.set_text('Cancel')
button_box = mforms.newBox(True)
button_box.set_spacing(8)
mforms.Utilities.add_end_ok_cancel_buttons(button_box, ok, cancel)
top_box = mforms.newBox(False)
top_box.set_padding(12)
top_box.set_spacing(8)
panel_box = mforms.newBox(False)
panel_box.set_spacing(12)
panel_box.set_padding(8)
panel_box.add(label, False, True)
top_box.add(panel_box, True, True)
top_box.add(button_box, True, True)
form.set_content(top_box)
form.center()
runModalOutput = form.run_modal(ok, cancel)
form.close() # doesn't actually close the form!!
print 'runModalOutput:'
print runModalOutput
print 'returning...'
return 0