Opened 9 years ago

Last modified 9 years ago

#5959 closed enhancement

Add a copy constructor to OGRFeatureDefn — at Version 2

Reported by: yzhong Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description (last modified by yzhong)

I think we should add a copy constructor to OGRFeatureDefn. Otherwise, the following code will crash. The reason is obvious that the memory of papoGeomFieldDefn is getting released.

        OGRFeatureDefn oFeatureDefn;
        oFeatureDefn = OGRFeatureDefn( pszLayerName );
        oFeatureDefn.SetGeomType( wkbNone ); // crash

If you don't want to implement the copy constructor, should at least mark it as delete (C++11) or make it private to prevent developers of making mistakes by calling it.

As a matter of fact, I think we need Rule of 5 to make it safe to use.

Change History (2)

comment:1 by yzhong, 9 years ago

Description: modified (diff)

comment:2 by yzhong, 9 years ago

Description: modified (diff)
Type: defectenhancement
Note: See TracTickets for help on using tickets.