Skip to content
Permalink
Browse files

[gpkg] Add test for gpkg subsetstring don't unlock mutex twice

I wanted to add the test for gpkg subsetstring even if
it was not bugged, while testing that, I hit an assert
in Qt core that pointed me to double unlocked locks.
  • Loading branch information
elpaso committed Jan 25, 2018
1 parent cd0559d commit 698befa9dd21ff3a64c483cbc84680ab47d28143
@@ -5258,7 +5258,6 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS
if ( !hLayer )
{
errCause = QObject::tr( "Unable to save layer style. It's not possible to create the destination table on the database." );
mutex->unlock();
return false;
}
bool ok = true;
@@ -5322,7 +5321,6 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS
if ( !ok )
{
errCause = QObject::tr( "Unable to save layer style. It's not possible to create the destination table on the database." );
mutex->unlock();
return false;
}
}
@@ -5379,7 +5377,6 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::No ) )
{
errCause = QObject::tr( "Operation aborted" );
mutex->unlock();
return false;
}
bNew = false;
@@ -5431,8 +5428,6 @@ QGISEXTERN bool saveStyle( const QString &uri, const QString &qmlStyle, const QS
else
bFeatureOK = OGR_L_SetFeature( hLayer, hFeature.get() ) == OGRERR_NONE;

mutex->unlock();

if ( !bFeatureOK )
{
QgsMessageLog::logMessage( QObject::tr( "Error updating style" ) );
@@ -13,6 +13,7 @@
__revision__ = '$Format:%H$'

import os
import re
import shutil
import sys
import tempfile
@@ -860,6 +861,42 @@ def testSubSetStringEditable_bug17795(self):
vl.setSubsetString('')
self.assertTrue(vl.dataProvider().capabilities() & isEditable)

def testSubsetStringExtent_bug17863(self):
"""Check that the extent is correct when applied in the ctor and when
modified after a subset string is set """

def _lessdigits(s):
return re.sub(r'(\d+\.\d{3})\d+', r'\1', s)

testPath = TEST_DATA_DIR + '/' + 'provider/bug_17795.gpkg|layername=bug_17795'
subSetString = '"name" = \'int\''
subSet = '|layername=bug_17795|subset=%s' % subSetString

# unfiltered
vl = QgsVectorLayer(testPath, 'test', 'ogr')
self.assertTrue(vl.isValid())
unfiltered_extent = _lessdigits(vl.extent().toString())
del(vl)

# filter after construction ...
subSet_vl2 = QgsVectorLayer(testPath, 'test', 'ogr')
self.assertEqual(_lessdigits(subSet_vl2.extent().toString()), unfiltered_extent)
# ... apply filter now!
subSet_vl2.setSubsetString(subSetString)
self.assertEqual(subSet_vl2.subsetString(), subSetString)
self.assertNotEqual(_lessdigits(subSet_vl2.extent().toString()), unfiltered_extent)
filtered_extent = _lessdigits(subSet_vl2.extent().toString())
del(subSet_vl2)

# filtered in constructor
subSet_vl = QgsVectorLayer(testPath + subSet, 'subset_test', 'ogr')
self.assertEqual(subSet_vl.subsetString(), subSetString)
self.assertTrue(subSet_vl.isValid())

# This was failing in bug 17863
self.assertEqual(_lessdigits(subSet_vl.extent().toString()), filtered_extent)
self.assertNotEqual(_lessdigits(subSet_vl.extent().toString()), unfiltered_extent)


if __name__ == '__main__':
unittest.main()
Binary file not shown.

0 comments on commit 698befa

Please sign in to comment.
You can’t perform that action at this time.