mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-30 00:29:39 -05:00
fix(MapLayer): Avoid crash when error list is empty
This commit is contained in:
parent
9e12e2d59c
commit
56b17dba74
@ -129,5 +129,5 @@ QString QgsError::message( QgsErrorMessage::Format format ) const
|
||||
QString QgsError::summary() const
|
||||
{
|
||||
// The first message in chain is usually the real error given by backend/server
|
||||
return mMessageList.first().message();
|
||||
return ( mMessageList.isEmpty() ? QString() : mMessageList.first().message() );
|
||||
}
|
||||
|
||||
@ -542,6 +542,14 @@ class TestQgsMapLayer(QgisTestCase):
|
||||
self.assertFalse(rl.mapTipTemplate())
|
||||
self.assertFalse(rl.hasMapTips())
|
||||
|
||||
def testError(self):
|
||||
"""
|
||||
Test error reporting methods
|
||||
"""
|
||||
vl = QgsVectorLayer("ErrorString", "test", "error")
|
||||
self.assertFalse(vl.isValid())
|
||||
self.assertEqual(vl.error().summary(), "")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user