openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #18509
[Merge] lp:~j-corwin/openlp/bug-1094198 into lp:openlp/2.0
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/bug-1094198 into lp:openlp/2.0.
Requested reviews:
OpenLP Core (openlp-core)
Related bugs:
Bug #1094198 in OpenLP: "Setting Import fails to find General section"
https://bugs.launchpad.net/openlp/+bug/1094198
For more details, see:
https://code.launchpad.net/~j-corwin/openlp/bug-1094198/+merge/141469
** 2.0 **
Attempt to successfully import the settings we can now export.
* QSettings exports the 'general' group as '%General' but appears in some circumstances (Linux?) to struggle to import this again. Try and compensate.
* If you run 2.1, even if just the once, it'll create a [players] settings group. If you later go back to 2.0 it'll load this group (even if it doesn't use it) and so it'll be exported. However the import considers the group invalid so fails. I've therefore changed the import to be more forgiving and just ignore unknown groups. A basic sanity test is done earlier instead. (Using the same string to avoid translation problems)
Tim please can you see if this solves your problem? Ta.
--
https://code.launchpad.net/~j-corwin/openlp/bug-1094198/+merge/141469
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/bug-1094198 into lp:openlp/2.0.
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2012-11-11 21:16:14 +0000
+++ openlp/core/ui/mainwindow.py 2012-12-29 23:04:23 +0000
@@ -982,6 +982,22 @@
settings = Settings()
import_settings = Settings(import_file_name,
Settings.IniFormat)
+ # Lets do a basic sanity check. If it contains this string we can
+ # assume it was created by OpenLP and so we'll load what we can
+ # from it, and just silently ignore anything we don't recognise
+ if import_settings.value(u'SettingsImport/type').toString() \
+ != u'OpenLP_settings_export':
+ QtGui.QMessageBox.critical(self,
+ translate('OpenLP.MainWindow', 'Import settings'),
+ translate('OpenLP.MainWindow',
+ 'The file you selected does appear to be a valid OpenLP '
+ 'settings file.\n\n'
+ 'Section [%s] is not valid \n\n'
+ 'Processing has terminated and no changed have been made.'
+ ).replace('%s', u'SettingsImport'),
+ QtGui.QMessageBox.StandardButtons(
+ QtGui.QMessageBox.Ok))
+ return
import_keys = import_settings.allKeys()
for section_key in import_keys:
# We need to handle the really bad files.
@@ -991,22 +1007,12 @@
section = u'unknown'
key = u''
# Switch General back to lowercase.
- if section == u'General':
+ if section == u'General' or section == u'%General':
section = u'general'
section_key = section + "/" + key
# Make sure it's a valid section for us.
if not section in setting_sections:
- QtGui.QMessageBox.critical(self,
- translate('OpenLP.MainWindow', 'Import settings'),
- translate('OpenLP.MainWindow',
- 'The file you selected does appear to be a valid OpenLP '
- 'settings file.\n\n'
- 'Section [%s] is not valid \n\n'
- 'Processing has terminated and no changed have been made.'
- ).replace('%s', section),
- QtGui.QMessageBox.StandardButtons(
- QtGui.QMessageBox.Ok))
- return
+ continue
# We have a good file, import it.
for section_key in import_keys:
value = import_settings.value(section_key)
Follow ups