Thanks Rafael,  I think I know the real fix, will work on it this
afternoon.

Cheers,
Jackson


On Wed, 2006-06-28 at 12:03 -0300, Rafael Teixeira wrote:
> **Description of Problem:
> 
> When starting a WinForms application on a station with the ABNT2
> (Brazilian 105-Key Keyboard) layout, we have a "Array index is out of
> range." exception in <0x0043e>
> System.Windows.Forms.X11Keyboard:CreateConversionArray that kills the
> app.
> 
> **Steps to reproduce the problem:
> 1. Just run a SWF app, with that keyboard layout set on X11.
> 
> **Actual Results:
> 
> Unhandled Exception: System.TypeInitializationException: An exception
> was thrown by the type initializer for System.Windows.Forms.XplatUI --->
> System.IndexOutOfRangeException: Array index is out of range.
> in <0x0043e> System.Windows.Forms.X11Keyboard:CreateConversionArray
> (System.Windows.Forms.KeyboardLayouts layouts,
> System.Windows.Forms.KeyboardLayout layout)
> in <0x000d8> System.Windows.Forms.X11Keyboard:.ctor (IntPtr display,
> IntPtr window)
> in <0x003e9> System.Windows.Forms.XplatUIX11:SetDisplay (IntPtr
> display_handle)
> in <0x0008b> System.Windows.Forms.XplatUIX11:.ctor ()
> in <0x00040> System.Windows.Forms.XplatUIX11:GetInstance ()
> in <0x00061> System.Windows.Forms.XplatUI:.cctor ()--- End of inner
> exception stack trace ---
> 
> in <0x00000> <unknown method>
> in <0x00064> System.Windows.Forms.Form:get_CreateParams ()
> in <0x00273> System.Windows.Forms.Control:.ctor ()
> in <0x00011> System.Windows.Forms.ScrollableControl:.ctor ()
> in <0x00010> System.Windows.Forms.ContainerControl:.ctor ()
> in <0x00019> System.Windows.Forms.Form:.ctor ()
> in <0x00017> TestGUIWordCount.Form1:.ctor ()
> in (wrapper remoting-invoke-with-check) TestGUIWordCount.Form1:.ctor ()
> in <0x00018> TestGUIWordCount.Form1:Main ()
> 
> **Expected Results:
> Just showing the app form.
> 
> **How often does this happen?
> 
> Always for that keyboard layout.
> 
> **Additional Information:
> 
> This patch, deals with the exception so the app runs, and shows some
> debugging information that may lead to the correct fix:
> 
> Index: System.Windows.Forms/X11Keyboard.cs
> ===================================================================
> --- System.Windows.Forms/X11Keyboard.cs       (revision 61762)
> +++ System.Windows.Forms/X11Keyboard.cs       (working copy)
> @@ -497,14 +498,25 @@
>                                                       }
>                                               }
>                                               if (maxval >= 0) {
> -                                                     scan = 
> layouts.scan_table [(int) layout.ScanIndex][maxval];
> -                                                     vkey = 
> layouts.vkey_table [(int) layout.VKeyIndex][maxval];
> +                                                     try {
> +                                                             scan = 
> layouts.scan_table [(int) layout.ScanIndex][maxval];
> +                                                             vkey = 
> layouts.vkey_table [(int) layout.VKeyIndex][maxval];
> +                                                     } catch (Exception e) {
> +                                                             
> Console.WriteLine("Ignoring invalid indexes '{0}' '{1}'
> '{2}'", (int) layout.ScanIndex, (int) layout.VKeyIndex, maxval);
> +                                                     
> +                                                             scan = 0;
> +                                                             vkey = 0;
> +                                                     }
>                                               }
>                                               
>                                       }
>                               }
> -                             keyc2vkey [e2.KeyEvent.keycode] = vkey;
> -                             keyc2scan [e2.KeyEvent.keycode] = scan;
> +                             if (e2.KeyEvent.keycode < 0 || 
> e2.KeyEvent.keycode > 255)
> +                                     Console.WriteLine("Ignoring invalid 
> keycode found '{0}'",
> e2.KeyEvent.keycode);
> +                             else {
> +                                     keyc2vkey [e2.KeyEvent.keycode] = vkey;
> +                                     keyc2scan [e2.KeyEvent.keycode] = scan;
> +                             }
>                       }
> 
> 

_______________________________________________
Mono-winforms-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to