[IronPython] Intermittent Bug: Loading a py file crashes winforms
Dino Viehland
dinov at exchange.microsoft.com
Tue Apr 4 21:58:20 CEST 2006
The issue here is w/ the timing of starting up the Winforms thread and returning control back to your module. This will be fixed in beta 6, but you can make the change to winforms.py yourself by adding the marked 4 lines:
from System.Drawing import Size
from System.Windows.Forms import Form, Application
from System.Threading import Thread
from IronPython.Runtime import CallTarget0
from System.Threading import AutoResetEvent # add me
import IronPython
are = AutoResetEvent(False) # add me
def thread_proc():
global dispatcher
dispatcher = Form(Size = Size(0,0))
dispatcher.Show()
dispatcher.Hide()
are.Set() # add me
Application.Run()
def callback(code):
if code:
dispatcher.Invoke(CallTarget0(code))
else:
Application.Exit()
t = Thread(thread_proc)
t.Start()
are.WaitOne() # add me
IronPython.Hosting.PythonEngine.ExecWrapper = callback
Do you want to help develop Dynamic languages on CLR? (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-11F0-45DF-8B78-DC1B43134038)
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Mat Steeples
Sent: Monday, April 03, 2006 3:00 AM
To: users at lists.ironpython.com
Subject: [IronPython] Intermittent Bug: Loading a py file crashes winforms
Hi
Sorry to keep posting new bugs like this. This one's quite a weird one.
I've written a small .py file (attached) that when loading has some
strange errors.
If I type the code in by hand, then it runs no problems. If i drag the
file over IronPythonConsole.exe, then it brings up the "Submit an error
report" message. If i double click the file (so it loads with
IronPythonConsole.exe) it runs fine (although the console window doesn't
disappear when the form closes), and if I open IronPythonConsole and
import the file, it prints out the following.
1
2
3
Traceback (most recent call last):
File H:\IronPython-1.0-Beta5\sample.py, line 6, in Initialize
AttributeError: 'Form' object has no attribute 'ShowDialog'
Hope that's enough detail. The winforms.py file that I'm using is the one
in the templates directory, but I've copied it to the lib directory.
Regards,
Mat Steeples
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list