Ejemplo n.º 1
0
def ogr_refcount_1():
    if ogr.GetOpenDSCount() != 0:
        gdaltest.post_reason('Initial Open DS count is not zero!')
        return 'failed'

    gdaltest.ds_1 = ogr.OpenShared('data/idlink.dbf')
    gdaltest.ds_2 = ogr.OpenShared('data/poly.shp')

    if ogr.GetOpenDSCount() != 2:
        gdaltest.post_reason('Open DS count not 2 after shared opens.')
        return 'failed'

    if gdaltest.ds_1.GetRefCount() != 1 or gdaltest.ds_2.GetRefCount() != 1:
        gdaltest.post_reason('Reference count not 1 on one of datasources.')
        return 'failed'

    return 'success'
Ejemplo n.º 2
0
def ogr_refcount_cleanup():
    gdaltest.ds_2.Release()

    if ogr.GetOpenDSCount() != 0:
        gdaltest.post_reason('Open DS count not back to zero.')
        return 'failed'

    return 'success'
Ejemplo n.º 3
0
def ogr_refcount_3():

    gdaltest.ds_3.Release()

    if gdaltest.ds_1.GetRefCount() != 1:
        gdaltest.post_reason('Refcount not decremented as expected.')
        return 'failed'

    gdaltest.ds_1.Release()

    if ogr.GetOpenDSCount() != 1:
        gdaltest.post_reason('Open DS count not back to one.')
        return 'failed'

    return 'success'
Ejemplo n.º 4
0
def ogr_refcount_2():

    ds_3 = ogr.OpenShared('data/idlink.dbf')

    if ogr.GetOpenDSCount() != 2:
        gdaltest.post_reason('Open DS count not 2 after third open.')
        return 'failed'

    # This test only works with the old bindings.
    try:
        if ds_3._o != gdaltest.ds_1._o:
            gdaltest.post_reason('We did not get the expected pointer.')
            return 'failed'
    except:
        pass

    if ds_3.GetRefCount() != 2:
        gdaltest.post_reason('Refcount not 2 after reopened.')
        return 'failed'

    gdaltest.ds_3 = ds_3

    return 'success'