Opened 16 years ago

Closed 16 years ago

#2544 closed defect (fixed)

OGRRegisterAll registers duplicates if called more than once

Reported by: Mateusz Łoskot Owned by: warmerdam
Priority: normal Milestone: 1.6.0
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: ogr ogrregisterall
Cc:

Description

If OGRRegisterAll is called more than once, it duplicates drivers registration.

#include <ogrsf_frmts.h>
int main()
{
   OGRRegisterAll();

   OGRSFDriverRegistrar *poR = OGRSFDriverRegistrar::GetRegistrar();
   int n1 = poR->GetDriverCount();

   OGRRegisterAll();
   int n2 = poR->GetDriverCount();

   assert( n2 == 2 * n1 ); // SHOULD FAIL BUT IS TRUE
   
   return 0;
}

Honestly, I'm not sure if it is a known problem or expected behavior. My sense of taste says it does not work as expected.

Change History (1)

comment:1 by Even Rouault, 16 years ago

Milestone: 1.6.0
Resolution: fixed
Status: newclosed

There was a protection mechanism for GDAL drivers, so it makes sense to do the same thing for OGR ones.

Fixed in trunk in r15208

Note: See TracTickets for help on using tickets.