Does closing/hiding the parent form dispose of map data ?

Topics: Windows Forms
Jan 19, 2012 at 2:20 PM

Firstly, Thanks for this great library ! 

The issue is:

I use the GMapControl following way:

1) GMapControl control is created and added to a form upon form initialization

2) That form is not shown initially, but somewhere in the app, by button click

3) Upon first (only) form show event I initialize a new MapProvider and assign it to the map instance, so that any following "form.show" has the map ready and running. I found out that by simply closing the form, it disposes all it's managed ressources causing an Exception upon a subsequential "show"-call. Fixed that by showing the form as a dialog (closing it does not make a call to the "dispose" method by default). 

However, another type of NullReference exception still occures:

In Core.gs:

tileDrawingListLock.AcquireWriterLock()

 

tileDrawingListLock is null

Tried only hiding the form, instead of closing it, same thing.

I guess, there is still something that is being internally disposed by the GMap instance itself upon it's parent form close/hide.

Jan 19, 2012 at 2:31 PM

windows forms or wpf?

Jan 19, 2012 at 2:54 PM

windows forms

Jan 19, 2012 at 3:08 PM

control is disposed after OnHandleDestroyed is called, and that is when you close form, i don't know about hiding, need some testing...

Jan 19, 2012 at 3:16 PM

works perfectly, form2 contains map, and hiding doesn't dispose anything

public partial class Form1 : Form
{
Form2 form2;

public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if(form2 == null)
{
form2 = new Form2();
}
form2.Show();
}

private void button2_Click(object sender, EventArgs e)
{
if(form2 != null)
{
form2.Hide();
}
}
}

Feb 8, 2012 at 1:38 PM

I have similar problem, WPF

I have 2 maps on two tabs. I can switch between tabs without map without any problem. I can only once visit tab with map (one time each tab contains map), when I back to this tab second time aplication goes into deadlock.

I've tried knightlie's solution from here, but it didn't help.

NullReferenceException was unhandled

Core.cs, UpdateBounds()

tileDrawingListLock.AcquireWriterLock();

> GMap.NET.Core.dll!GMap.NET.Internals.Core.UpdateBounds() Line 1188 C#  GMap.NET.Core.dll!GMap.NET.Internals.Core.Drag(GMap.NET.GPoint pt) Line 865 + 0x8 bytes C#  GMap.NET.Core.dll!GMap.NET.Internals.Core.GoToCurrentPosition() Line 773 + 0x22 bytes C#  GMap.NET.Core.dll!GMap.NET.Internals.Core.OnMapOpen() Line 397 + 0x8 bytes C#  GMap.NET.WindowsPresentation.dll!GMap.NET.WindowsPresentation.GMapControl.GMapControl_Loaded(object sender, System.Windows.RoutedEventArgs e) Line 606 + 0x10 bytes C#  [External Code]

Feb 8, 2012 at 1:51 PM

it's fixed