Commit 4679b91f authored by Doug Turner's avatar Doug Turner
Browse files

[Bug 513342] crash while browsing to and from a geolocation page. r=blassey

parent 6eeff2e5
Loading
Loading
Loading
Loading
+29 −10
Original line number Diff line number Diff line
@@ -189,7 +189,13 @@ nsGeoPosition::GetAddress(nsIDOMGeoPositionAddress** aAddress)
NS_IMPL_ISUPPORTS2(WinMobileLocationProvider, nsIGeolocationProvider, nsITimerCallback)

WinMobileLocationProvider::WinMobileLocationProvider() :
mGPSDevice(nsnull), mHasSeenLocation(PR_FALSE)
  mGPSDevice(nsnull), 
  mOpenDevice(nsnull),
  mCloseDevice(nsnull),
  mGetPosition(nsnull),
  mGetDeviceState(nsnull),
  mHasSeenLocation(PR_FALSE),
  mHasGPS(PR_TRUE) /* think positively */
{
}

@@ -200,6 +206,9 @@ WinMobileLocationProvider::~WinMobileLocationProvider()
NS_IMETHODIMP
WinMobileLocationProvider::Notify(nsITimer* aTimer)
{
  if (!mGPSDevice || !mGetPosition)
    return NS_ERROR_FAILURE;

  GPS_POSITION pos;
  memset(&pos, 0, sizeof(GPS_POSITION));
  pos.dwVersion = GPS_VERSION_1;
@@ -230,10 +239,11 @@ WinMobileLocationProvider::Notify(nsITimer* aTimer)

NS_IMETHODIMP WinMobileLocationProvider::Startup()
{
  if (!mGPSDevice) {
  if (mHasGPS && !mGPSInst) {
    mGPSInst = LoadLibraryW(L"gpsapi.dll");
    
    if(!mGPSInst) {
      mHasGPS = PR_FALSE;
      NS_ASSERTION(mGPSInst, "failed to load library gpsapi.dll");
      return NS_ERROR_FAILURE;
    }
@@ -291,11 +301,20 @@ NS_IMETHODIMP WinMobileLocationProvider::Shutdown()
  if (mGPSDevice)
    mCloseDevice(mGPSDevice);

  mGPSDevice = nsnull;
  
  mHasSeenLocation = PR_FALSE;
  
  mCallback = nsnull;
  
  FreeLibrary(mGPSInst);
  mGPSInst = nsnull;

  mOpenDevice  = nsnull;
  mCloseDevice = nsnull;
  mGetPosition = nsnull;
  mGetDeviceState = nsnull;
 
  return NS_OK;
}

+2 −1
Original line number Diff line number Diff line
@@ -67,7 +67,8 @@ class WinMobileLocationProvider : public nsIGeolocationProvider,
  ~WinMobileLocationProvider();
  
  nsCOMPtr<nsIGeolocationUpdate> mCallback;
  PRBool mHasSeenLocation;
  PRPackedBool mHasSeenLocation;
  PRPackedBool mHasGPS;
  
  nsCOMPtr<nsITimer> mUpdateTimer;
  
+0 −8
Original line number Diff line number Diff line
@@ -386,7 +386,6 @@ nsresult nsGeolocationService::Init()
  if (provider)
    mProviders.AppendObject(provider);


  // look up any providers that were registered via the category manager
  nsCOMPtr<nsICategoryManager> catMan(do_GetService("@mozilla.org/categorymanager;1"));
  if (!catMan)
@@ -417,13 +416,6 @@ nsresult nsGeolocationService::Init()

  // we should move these providers outside of this file! dft

  // if NS_MAEMO_LOCATION, see if we should try the MAEMO location provider
#ifdef NS_MAEMO_LOCATION
  provider = new MaemoLocationProvider();
  if (provider)
    mProviders.AppendObject(provider);
#endif

  // if WINCE, see if we should try the WINCE location provider
#ifdef WINCE_WINDOWS_MOBILE
  provider = new WinMobileLocationProvider();