Comment 31 for bug 990960

Revision history for this message
ludo33200 (ludo-cheron) wrote :

I think there a t least 3 problems reported here

Concerning the following problem
>System.NullReferenceException: Object reference not set to an instance of an object
> at System.Windows.Forms.ListView+ItemControl.ItemsMouseDown (System.Object sender, >System.Windows.Forms.MouseEventArgs me) [0x00000] in <filename unknown>:0

Other mentionned bugs should have been reported elsewhere for other bugs (duplicates ?)

Ubuntu 15.04
+ OpenBVE 1.4.0.9-1 as installed
I reproduce this bug each time i try to select a route with the mouse (not with the keyboard)

After having tried to localize the problem with monoDevelop, i think i've found something that could cause the problem

When i read the source code, i see
OpenBve/OldCode/formMain.Start.cs,

private void ShowRoute(bool UserSelectedEncoding) {
   if (Result.RouteFile != null) {
    this.Cursor = Cursors.WaitCursor;
    Application.DoEvents();
    ]...[

C# Microsoft documentation suggests this code (Application.DoEvent call ) could cause problems
https://msdn.microsoft.com/en-US/library/system.windows.forms.application.doevents%28v=vs.110%29.aspx
You will find many posts on many forums about this topic

>Calling this method causes the current thread to be suspended while all waiting window messages are processed. If a message >causes an event to be triggered, then other areas of your application code may execute. This can cause your application to >exhibit unexpected behaviors that are difficult to debug.

What i see is that removing this instruction (Application.DoEvent call) seems to remove the problem and allowing to show the route.
As i'm not a premium developper i'm not directly going to change the code for OpenBve.
If anyone could validate or not the code ??

---------- Code suggested
private void ShowRoute(bool UserSelectedEncoding) {
   if (Result.RouteFile != null) {
    this.Cursor = Cursors.WaitCursor;
    if (!Program.CurrentlyRunningOnMono) { // disabled code on Mono because it makes crash
     Application.DoEvents();
    }
                                ]...[