Bug report #7735
QgsProject.writeEntry bugs with line endings
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Project Loading/Saving | ||
Affected QGIS version: | master | Regression?: | No |
Operating System: | windows | Easy fix?: | No |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 16641 |
Description
Hi !
When saving multiline strings with writeEntry, you get the following bug (tested on windows)
text = '''a b c''' QgsProject.instance().writeEntry('test','test',text) QgsProject.instance().readEntry('test','test')[0] # this works fine : prints PyQt4.QtCore.QString(u'a\ b\ c') # save and reopen file QgsProject.instance().readEntry('test','test')[0] # now, this prints PyQt4.QtCore.QString(u'a\ \ b\ \ c') # save and reopen file several time QgsProject.instance().readEntry('test','test')[0] # now, this prints PyQt4.QtCore.QString(u'a\ \ \ \ \ b\ \ \ \ \ c')
So you end up with a string having a lot of useless linebreaks... In the file, it looks like this :
<test> <test type="QString">a



 b



 c</test> </test>
Related issues
History
#1 Updated by Giuseppe Sucameli over 11 years ago
- Status changed from Open to Closed
Fixed in changeset 81f677d5019a3d0c8129aae9d4f0f88123110d2d.
#2 Updated by Olivier Dalang almost 11 years ago
- Status changed from Closed to Reopened
Hi ! It seems the bug reappeared (or never really disappeared ?!!).
It affects the "save query" feature of the DB manager but could also affect other elements.
The problem seems to be already present on 2.0.1 (but I could almost swear it worked well some time ago, maybe for 2.0 ?)
Thanks !!
text = '''a b c''' QgsProject.instance().writeEntry('test','test',text) QgsProject.instance().readEntry('test','test')[0] # this works fine : prints u'a\ b\ c' # save and reopen file QgsProject.instance().readEntry('test','test')[0] # now, this prints u'a\ \ b\ \ c' # save and reopen file several time QgsProject.instance().readEntry('test','test')[0] # now, this prints u'a\ \ \ \ \ b\ \ \ \ \ c'
#3 Updated by Giovanni Manghi almost 11 years ago
- Target version changed from Version 2.0.0 to Future Release - High Priority
#4 Updated by Jürgen Fischer over 10 years ago
- Category set to Project Loading/Saving
#5 Updated by Jürgen Fischer over 10 years ago
- Status changed from Reopened to Closed
Fixed in changeset d62a49810e6117d3b3815c9c2367f7ac745f054b.