[Mono-winforms-list] Control.Invoke Bug and Patch

2009-05-24 Thread Tom Spink
Hi Guys,

I submitted a bug (https://bugzilla.novell.com/show_bug.cgi?id=497175)
a while ago about Control.Invoke not propagating an exception thrown
in the callee back to the caller.  I made a patch which fixes this
issue, and I've been testing it with success for a while now.

I attached the patch to the bug, but it appears to have gotten lost in
the mists o' time... so I've attached it to this e-mail for review -
and hopefully inclusion into the source tree!

Thanks!
-- 
Tom Spink
Frank Lloyd Wright  - "TV is chewing gum for the eyes." -
http://www.brainyquote.com/quotes/authors/f/frank_lloyd_wright.html
Index: class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
===
--- class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs	(revision 132351)
+++ class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs	(working copy)
@@ -476,7 +476,19 @@
 		{
 			AsyncMethodData data = (AsyncMethodData) state;
 			AsyncMethodResult result = data.Result;
-			object ret = data.Method.DynamicInvoke (data.Args);
+			
+			object ret;
+			try {
+ret = data.Method.DynamicInvoke (data.Args);
+			} catch (Exception ex) {
+if (result != null) {
+	result.CompleteWithException (ex);
+	return;
+}
+
+throw ex;
+			}
+		
 			if (result != null) {
 result.Complete (ret);
 			}
@@ -513,7 +525,14 @@
 
 			try {
 AsyncMethodResult result = data.Result;
-object ret = data.Method.DynamicInvoke (data.Args);
+object ret;
+try {
+	ret = data.Method.DynamicInvoke (data.Args);
+} catch (Exception ex) {
+	result.CompleteWithException (ex);
+	return;
+}
+
 result.Complete (ret);
 			}
 			finally {
Index: class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs
===
--- class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs	(revision 132351)
+++ class/Managed.Windows.Forms/System.Windows.Forms/AsyncMethodResult.cs	(working copy)
@@ -34,6 +34,7 @@
 		private object state;
 		private bool completed;
 		private object return_value;
+		private Exception exception;
 
 		public AsyncMethodResult ()
 		{
@@ -68,10 +69,18 @@
 		public object EndInvoke ()
 		{
 			lock (this) {
-if (completed)
-	return return_value;
+if (completed) {
+	if (exception == null)
+		return return_value;
+	else
+		throw exception;
+}
 			}
 			handle.WaitOne ();
+			
+			if (exception != null)
+throw exception;
+
 			return return_value;
 		}
 
@@ -83,6 +92,15 @@
 handle.Set ();
 			}
 		}
+		
+		public void CompleteWithException (Exception ex)
+		{
+			lock (this) {
+completed = true;
+exception = ex;
+handle.Set ();
+			}
+		}
 	}
 
 }
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] Clipboard.SetDataObject() doing nothing

2009-05-24 Thread Christoph Teuber
doing that would be great. I did try to copy other data to clipboard
because I'm working on an small app syncing two clipboards over the LAN.
So I try to copy Windows clipboard contents on Linux. For my own
personal needs, it should work across platform boundaries, but text is
enough. Which works. But other people may have other needs, so I try to
support different formats.

What confuses me is, that clipboard handling within X11 seems to be
quite complicated. For other formats than text, most applications I
tried seem to use their one clipboard. Cutting in Gimp doesn't paste in
OpenOffice Draw and vice versa. So maybe supporting other formats
wouldn't be that usefull, but having the capability of copy and paste
other formats between mono applications would be a good start.

Does anybody of you know a good document explaining the situation?

cht


Carlos Alberto Cortez wrote:
> I already did some refactoring code to handle formats other than text,
> we only need to copy the information just as other x11 applications do
> that :-)
>
> But anyway, feel free a magicalto send (me) those notes as well :-)
>
> Carlos.
>
> 2009/5/24 Ivan N. Zlatev mailto:cont...@i-nz.net>>
>
> Hey,
>
> There is already a bug for this:
> https://bugzilla.novell.com/show_bug.cgi?id=357642
>
> Basically we don't support IDataObject and custom data (clipboard)
> formats and just hand-check for text and handle that in a magical way.
> The best way (imho) to fix this is to have a IDataObject centric
> clipboard implementation. I have some notes if someone is interested.
>
>
> On Sun, May 24, 2009 at 4:33 PM, Carlos Alberto Cortez
> mailto:calberto.cor...@gmail.com>> wrote:
> > This issue has nothing to see with that Changelog entry.
> >
> > Basically we have never supported copying/pasting other than
> text/rtf text.
> > So feel free to open a bug report for it :-)
> >
> > Thanks!
> > Carlos.
> >
> >
> > 2009/5/24 Christoph Teuber  >
> >>
> >> Hello,
> >>
> >> thanks for your fast answer.
> >>
> >> You were right, there were several changes, but nothing seems to be
> >> connected with my SetDataObject() problem. But I found this
> statement:
> >>
> >> 2007-03-18 Jackson Harper  >
> >>
> >> * TextBoxBase.cs: Remove image pasting code for now. There is no
> >> way to get an image on the clipboard right now anyways.
> >>
> >> This ist from 2007, so it may be out of date, but does it mean,
> that
> >> copying images to the clipboard doesn't work at all? I wonder,
> because
> >>
> >> Clipboard.SetImage( im );
> >>
> >> or
> >>
> >> Clipboard.SetObjectData( im );
> >>
> >> doesn't do anything either. (im is an image loaded as posted
> before). In
> >> contrary,
> >>
> >> Clipboard.SetObjectData("this is a test");
> >>
> >> does work.
> >>
> >> Greetings
> >> cht
> >>
> >>
> >>
> >> Stifu wrote:
> >> > I know there've been clipboard fixes after 2.4, so you could
> check out
> >> > SVN
> >> > (or bugzilla).
> >> >
> >> >
> >> > cht wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> I'm trying to do some clipboard stuff under Mono right now,
> and I have
> >> >> the
> >> >> problem, that Windows.Forms.Clipboard.SetDataObject()
> doesn't seem to
> >> >> do
> >> >> anything if a DataObject will be passed.
> >> >>
> >> >> I do have the following two pieces of code, which both run
> under .NET
> >> >> 2.0,
> >> >> but running under mono (2.0.1, Ubuntu 9.04) leaves the clipboard
> >> >> completely unchanged.
> >> >>
> >> >> private void testButton_Click(object sender, EventArgs e)
> >> >> {
> >> >> Image im = (Image)Bitmap.FromFile("test.jpg");
> >> >> DataObject dataObj = new DataObject();
> >> >> dataObj.SetData(im.GetType().ToString(), im);
> >> >> Clipboard.SetDataObject(dataObj, true);
> >> >>
> >> >> }
> >> >>
> >> >> private void testTextButton_Click(object sender, EventArgs e)
> >> >> {
> >> >> DataObject dataObj = new DataObject();
> >> >> string format = "System.String";
> >> >> dataObj.SetData(format, "this is a test");
> >> >> Clipboard.SetDataObject(dataObj, false);
> >> >> }
> >> >>
> >> >>
> >> >> I compile using VS 2008.
> >> >> As Clipboard.cs seems to bee unchanged since 2.0.1, I didn't try
> >> >> installing Mono 2.4. But I would like to stay compatible to
> 2.0.1
> >> >> anyway,
> >> >> so I hope I'm doing something wrong.
> >> >>
> >> >> Anybody any idea, why this is the case?
> >> >>
> >> >> Thanks in advan

Re: [Mono-winforms-list] Clipboard.SetDataObject() doing nothing

2009-05-24 Thread Carlos Alberto Cortez
I already did some refactoring code to handle formats other than text, we
only need to copy the information just as other x11 applications do that :-)

But anyway, feel free to send (me) those notes as well :-)

Carlos.

2009/5/24 Ivan N. Zlatev 

> Hey,
>
> There is already a bug for this:
> https://bugzilla.novell.com/show_bug.cgi?id=357642
>
> Basically we don't support IDataObject and custom data (clipboard)
> formats and just hand-check for text and handle that in a magical way.
> The best way (imho) to fix this is to have a IDataObject centric
> clipboard implementation. I have some notes if someone is interested.
>
>
> On Sun, May 24, 2009 at 4:33 PM, Carlos Alberto Cortez
>  wrote:
> > This issue has nothing to see with that Changelog entry.
> >
> > Basically we have never supported copying/pasting other than text/rtf
> text.
> > So feel free to open a bug report for it :-)
> >
> > Thanks!
> > Carlos.
> >
> >
> > 2009/5/24 Christoph Teuber 
> >>
> >> Hello,
> >>
> >> thanks for your fast answer.
> >>
> >> You were right, there were several changes, but nothing seems to be
> >> connected with my SetDataObject() problem. But I found this statement:
> >>
> >> 2007-03-18 Jackson Harper 
> >>
> >> * TextBoxBase.cs: Remove image pasting code for now. There is no
> >> way to get an image on the clipboard right now anyways.
> >>
> >> This ist from 2007, so it may be out of date, but does it mean, that
> >> copying images to the clipboard doesn't work at all? I wonder, because
> >>
> >> Clipboard.SetImage( im );
> >>
> >> or
> >>
> >> Clipboard.SetObjectData( im );
> >>
> >> doesn't do anything either. (im is an image loaded as posted before). In
> >> contrary,
> >>
> >> Clipboard.SetObjectData("this is a test");
> >>
> >> does work.
> >>
> >> Greetings
> >> cht
> >>
> >>
> >>
> >> Stifu wrote:
> >> > I know there've been clipboard fixes after 2.4, so you could check out
> >> > SVN
> >> > (or bugzilla).
> >> >
> >> >
> >> > cht wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> I'm trying to do some clipboard stuff under Mono right now, and I
> have
> >> >> the
> >> >> problem, that Windows.Forms.Clipboard.SetDataObject() doesn't seem to
> >> >> do
> >> >> anything if a DataObject will be passed.
> >> >>
> >> >> I do have the following two pieces of code, which both run under .NET
> >> >> 2.0,
> >> >> but running under mono (2.0.1, Ubuntu 9.04) leaves the clipboard
> >> >> completely unchanged.
> >> >>
> >> >> private void testButton_Click(object sender, EventArgs e)
> >> >> {
> >> >> Image im = (Image)Bitmap.FromFile("test.jpg");
> >> >> DataObject dataObj = new DataObject();
> >> >> dataObj.SetData(im.GetType().ToString(), im);
> >> >> Clipboard.SetDataObject(dataObj, true);
> >> >>
> >> >> }
> >> >>
> >> >> private void testTextButton_Click(object sender, EventArgs e)
> >> >> {
> >> >> DataObject dataObj = new DataObject();
> >> >> string format = "System.String";
> >> >> dataObj.SetData(format, "this is a test");
> >> >> Clipboard.SetDataObject(dataObj, false);
> >> >> }
> >> >>
> >> >>
> >> >> I compile using VS 2008.
> >> >> As Clipboard.cs seems to bee unchanged since 2.0.1, I didn't try
> >> >> installing Mono 2.4. But I would like to stay compatible to 2.0.1
> >> >> anyway,
> >> >> so I hope I'm doing something wrong.
> >> >>
> >> >> Anybody any idea, why this is the case?
> >> >>
> >> >> Thanks in advance
> >> >> cht
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> ___
> >> Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
> >> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
> >
> >
> > ___
> > Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-winforms-list
> >
> >
>
>
>
> --
> Kind Regards,
> Ivan N. Zlatev
>
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] Clipboard.SetDataObject() doing nothing

2009-05-24 Thread Ivan N. Zlatev
Hey,

There is already a bug for this:
https://bugzilla.novell.com/show_bug.cgi?id=357642

Basically we don't support IDataObject and custom data (clipboard)
formats and just hand-check for text and handle that in a magical way.
The best way (imho) to fix this is to have a IDataObject centric
clipboard implementation. I have some notes if someone is interested.


On Sun, May 24, 2009 at 4:33 PM, Carlos Alberto Cortez
 wrote:
> This issue has nothing to see with that Changelog entry.
>
> Basically we have never supported copying/pasting other than text/rtf text.
> So feel free to open a bug report for it :-)
>
> Thanks!
> Carlos.
>
>
> 2009/5/24 Christoph Teuber 
>>
>> Hello,
>>
>> thanks for your fast answer.
>>
>> You were right, there were several changes, but nothing seems to be
>> connected with my SetDataObject() problem. But I found this statement:
>>
>> 2007-03-18 Jackson Harper 
>>
>> * TextBoxBase.cs: Remove image pasting code for now. There is no
>> way to get an image on the clipboard right now anyways.
>>
>> This ist from 2007, so it may be out of date, but does it mean, that
>> copying images to the clipboard doesn't work at all? I wonder, because
>>
>> Clipboard.SetImage( im );
>>
>> or
>>
>> Clipboard.SetObjectData( im );
>>
>> doesn't do anything either. (im is an image loaded as posted before). In
>> contrary,
>>
>> Clipboard.SetObjectData("this is a test");
>>
>> does work.
>>
>> Greetings
>> cht
>>
>>
>>
>> Stifu wrote:
>> > I know there've been clipboard fixes after 2.4, so you could check out
>> > SVN
>> > (or bugzilla).
>> >
>> >
>> > cht wrote:
>> >
>> >> Hello,
>> >>
>> >> I'm trying to do some clipboard stuff under Mono right now, and I have
>> >> the
>> >> problem, that Windows.Forms.Clipboard.SetDataObject() doesn't seem to
>> >> do
>> >> anything if a DataObject will be passed.
>> >>
>> >> I do have the following two pieces of code, which both run under .NET
>> >> 2.0,
>> >> but running under mono (2.0.1, Ubuntu 9.04) leaves the clipboard
>> >> completely unchanged.
>> >>
>> >> private void testButton_Click(object sender, EventArgs e)
>> >>         {
>> >>             Image im = (Image)Bitmap.FromFile("test.jpg");
>> >>             DataObject dataObj = new DataObject();
>> >>             dataObj.SetData(im.GetType().ToString(), im);
>> >>             Clipboard.SetDataObject(dataObj, true);
>> >>
>> >>         }
>> >>
>> >> private void testTextButton_Click(object sender, EventArgs e)
>> >>         {
>> >>             DataObject dataObj = new DataObject();
>> >>             string format = "System.String";
>> >>             dataObj.SetData(format, "this is a test");
>> >>             Clipboard.SetDataObject(dataObj, false);
>> >>         }
>> >>
>> >>
>> >> I compile using VS 2008.
>> >> As Clipboard.cs seems to bee unchanged since 2.0.1, I didn't try
>> >> installing Mono 2.4. But I would like to stay compatible to 2.0.1
>> >> anyway,
>> >> so I hope I'm doing something wrong.
>> >>
>> >> Anybody any idea, why this is the case?
>> >>
>> >> Thanks in advance
>> >> cht
>> >>
>> >>
>> >>
>> >
>> >
>>
>> ___
>> Mono-winforms-list maillist  -  mono-winforms-l...@lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
>
> ___
> Mono-winforms-list maillist  -  mono-winforms-l...@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
>



-- 
Kind Regards,
Ivan N. Zlatev
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] Clipboard.SetDataObject() doing nothing

2009-05-24 Thread Carlos Alberto Cortez
This issue has nothing to see with that Changelog entry.

Basically we have never supported copying/pasting other than text/rtf text.
So feel free to open a bug report for it :-)

Thanks!
Carlos.


2009/5/24 Christoph Teuber 

> Hello,
>
> thanks for your fast answer.
>
> You were right, there were several changes, but nothing seems to be
> connected with my SetDataObject() problem. But I found this statement:
>
> 2007-03-18 Jackson Harper 
>
> * TextBoxBase.cs: Remove image pasting code for now. There is no
> way to get an image on the clipboard right now anyways.
>
> This ist from 2007, so it may be out of date, but does it mean, that
> copying images to the clipboard doesn't work at all? I wonder, because
>
> Clipboard.SetImage( im );
>
> or
>
> Clipboard.SetObjectData( im );
>
> doesn't do anything either. (im is an image loaded as posted before). In
> contrary,
>
> Clipboard.SetObjectData("this is a test");
>
> does work.
>
> Greetings
> cht
>
>
>
> Stifu wrote:
> > I know there've been clipboard fixes after 2.4, so you could check out
> SVN
> > (or bugzilla).
> >
> >
> > cht wrote:
> >
> >> Hello,
> >>
> >> I'm trying to do some clipboard stuff under Mono right now, and I have
> the
> >> problem, that Windows.Forms.Clipboard.SetDataObject() doesn't seem to do
> >> anything if a DataObject will be passed.
> >>
> >> I do have the following two pieces of code, which both run under .NET
> 2.0,
> >> but running under mono (2.0.1, Ubuntu 9.04) leaves the clipboard
> >> completely unchanged.
> >>
> >> private void testButton_Click(object sender, EventArgs e)
> >> {
> >> Image im = (Image)Bitmap.FromFile("test.jpg");
> >> DataObject dataObj = new DataObject();
> >> dataObj.SetData(im.GetType().ToString(), im);
> >> Clipboard.SetDataObject(dataObj, true);
> >>
> >> }
> >>
> >> private void testTextButton_Click(object sender, EventArgs e)
> >> {
> >> DataObject dataObj = new DataObject();
> >> string format = "System.String";
> >> dataObj.SetData(format, "this is a test");
> >> Clipboard.SetDataObject(dataObj, false);
> >> }
> >>
> >>
> >> I compile using VS 2008.
> >> As Clipboard.cs seems to bee unchanged since 2.0.1, I didn't try
> >> installing Mono 2.4. But I would like to stay compatible to 2.0.1
> anyway,
> >> so I hope I'm doing something wrong.
> >>
> >> Anybody any idea, why this is the case?
> >>
> >> Thanks in advance
> >> cht
> >>
> >>
> >>
> >
> >
>
> ___
> Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>
___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Re: [Mono-winforms-list] Clipboard.SetDataObject() doing nothing

2009-05-24 Thread Christoph Teuber
Hello,

thanks for your fast answer.

You were right, there were several changes, but nothing seems to be
connected with my SetDataObject() problem. But I found this statement:

2007-03-18 Jackson Harper 

* TextBoxBase.cs: Remove image pasting code for now. There is no
way to get an image on the clipboard right now anyways.

This ist from 2007, so it may be out of date, but does it mean, that
copying images to the clipboard doesn't work at all? I wonder, because

Clipboard.SetImage( im );

or

Clipboard.SetObjectData( im );

doesn't do anything either. (im is an image loaded as posted before). In
contrary,

Clipboard.SetObjectData("this is a test");

does work.

Greetings
cht



Stifu wrote:
> I know there've been clipboard fixes after 2.4, so you could check out SVN
> (or bugzilla).
>
>
> cht wrote:
>   
>> Hello, 
>>
>> I'm trying to do some clipboard stuff under Mono right now, and I have the
>> problem, that Windows.Forms.Clipboard.SetDataObject() doesn't seem to do
>> anything if a DataObject will be passed. 
>>
>> I do have the following two pieces of code, which both run under .NET 2.0,
>> but running under mono (2.0.1, Ubuntu 9.04) leaves the clipboard
>> completely unchanged. 
>>
>> private void testButton_Click(object sender, EventArgs e)
>> {
>> Image im = (Image)Bitmap.FromFile("test.jpg");
>> DataObject dataObj = new DataObject();
>> dataObj.SetData(im.GetType().ToString(), im);
>> Clipboard.SetDataObject(dataObj, true);
>>  
>> }
>>
>> private void testTextButton_Click(object sender, EventArgs e)
>> {
>> DataObject dataObj = new DataObject();
>> string format = "System.String";
>> dataObj.SetData(format, "this is a test");
>> Clipboard.SetDataObject(dataObj, false);  
>> }
>>
>>
>> I compile using VS 2008.
>> As Clipboard.cs seems to bee unchanged since 2.0.1, I didn't try
>> installing Mono 2.4. But I would like to stay compatible to 2.0.1 anyway,
>> so I hope I'm doing something wrong.
>>
>> Anybody any idea, why this is the case? 
>>
>> Thanks in advance 
>> cht
>>
>>
>> 
>
>   

___
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list