Missing null checking in WindowsForms.GMapOverlay

Topics: Bugs, Windows Forms
Dec 23, 2011 at 4:40 PM

Hi radioman!

In GMap.NET.WindowsForms.GMapOverlay class, the setter for IsVisible property should go from this:

 

public bool IsVisibile
      {
         get
         {
            return isVisibile;
         }
         set
         {
            if(value != isVisibile)
            {
               isVisibile = value;
               if(isVisibile)
               {
                  Control.HoldInvalidation = true;
                  ForceUpdate();
                  Control.Refresh();
               }
               else
               {
                  if(!Control.HoldInvalidation)
                  {
                     Control.Core.Refresh.Set();
                  }
               }
            }
         }
      }

 

... to this (just added null check for Control property):

public bool IsVisibile
      {
         get
         {
            return isVisibile;
         }
         set
         {
            if(value != isVisibile)
            {
               isVisibile = value;
               if (Control != null)
               {
                   if (isVisibile)
                   {
                       Control.HoldInvalidation = true;
                       ForceUpdate();
                       Control.Refresh();
                   }
                   else
                   {
                       if (!Control.HoldInvalidation)
                       {
                           Control.Core.Refresh.Set();
                       }
                   }
               }
            }
         }
      }

 

 

Didn't think this minor change needed a fork so posted here, but if you want, tell me so.

Thanks!
Guillermo

Jan 9, 2012 at 11:45 AM

thanks! fixed