Skip to content
Permalink
Browse files

Merge pull request #8324 from elpaso/bugfix-unreported-ensure-qml-ext…

…ention-on-save-style-to-file

Bugfix unreported ensure qml extention on save style to file
  • Loading branch information
elpaso committed Oct 25, 2018
2 parents 4acb12d + 6afb8de commit b0104a28076074f9a8ce253c55816e847256663b
Showing with 16 additions and 0 deletions.
  1. +5 −0 src/app/qgisapp.cpp
  2. +11 −0 tests/src/python/test_qgsmaplayer.py
@@ -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 @@
# 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 @@
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 @@ def testReadWriteMetadata(self):
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()

0 comments on commit b0104a2

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