mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
Merge pull request #8324 from elpaso/bugfix-unreported-ensure-qml-extention-on-save-style-to-file
Bugfix unreported ensure qml extention on save style to file
This commit is contained in:
commit
b0104a2807
@ -7398,6 +7398,11 @@ void QgisApp::saveStyleFile( QgsMapLayer *layer )
|
||||
if ( filename.isEmpty() )
|
||||
return;
|
||||
|
||||
if ( ! filename.endsWith( QStringLiteral( ".qml" ) ) )
|
||||
{
|
||||
filename += QStringLiteral( ".qml" );
|
||||
}
|
||||
|
||||
bool defaultLoadedFlag;
|
||||
layer->saveNamedStyle( filename, defaultLoadedFlag );
|
||||
|
||||
|
@ -12,6 +12,7 @@ __copyright__ = 'Copyright 2017, The QGIS Project'
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import qgis # NOQA
|
||||
import tempfile
|
||||
|
||||
@ -20,6 +21,7 @@ from qgis.core import (QgsReadWriteContext,
|
||||
QgsProject)
|
||||
from qgis.testing import start_app, unittest
|
||||
from qgis.PyQt.QtXml import QDomDocument
|
||||
from qgis.PyQt.QtCore import QTemporaryDir
|
||||
|
||||
start_app()
|
||||
|
||||
@ -105,6 +107,15 @@ class TestQgsMapLayer(unittest.TestCase):
|
||||
self.assertTrue(status)
|
||||
self.assertTrue(layer2.metadata().abstract(), 'My abstract')
|
||||
|
||||
def testSaveNamedStyle(self):
|
||||
layer = QgsVectorLayer("Point?field=fldtxt:string", "layer", "memory")
|
||||
dir = QTemporaryDir()
|
||||
dir_path = dir.path()
|
||||
style_path = os.path.join(dir_path, 'my.qml')
|
||||
_, result = layer.saveNamedStyle(style_path)
|
||||
self.assertTrue(result)
|
||||
self.assertTrue(os.path.exists(style_path))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user