From 1ce88e7a2a852446750c61ee1eb460a002fc0880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 15 Mar 2011 00:29:02 +0200 Subject: [PATCH 1/6] Prevent possible crash, if label field is empty in database. --- openlp/plugins/songs/forms/editsongform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0d9121c45..069e1e4a8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -269,6 +269,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if index is None: index = VerseType.Other verse[0][u'type'] = VerseType.Tags[index] + if verse[0][u'label'] == u'': + verse[0][u'label'] = u'1' verse_def = u'%s%s' % (verse[0][u'type'], verse[0][u'label']) item = QtGui.QTableWidgetItem(verse[1]) item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def)) From e5b664663a335666b6b509860b53f4392f10e3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 15 Mar 2011 01:05:31 +0200 Subject: [PATCH 2/6] Fix tracebacks, if user has no internet connection and he still presses Finish. --- openlp/core/ui/mainwindow.py | 2 ++ openlp/plugins/songs/songsplugin.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 06b809a20..2af6f3e59 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -678,6 +678,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): plugin.firstTime() Receiver.send_message(u'openlp_process_events') temp_dir = os.path.join(unicode(gettempdir()), u'openlp') + if not os.path.isdir(temp_dir): + return for filename in os.listdir(temp_dir): os.remove(os.path.join(temp_dir, filename)) os.removedirs(temp_dir) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index bd953ffac..1d3f12ede 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -255,6 +255,8 @@ class SongsPlugin(Plugin): """ db_dir = unicode(os.path.join(gettempdir(), u'openlp')) song_dbs = [] + if not os.path.isdir(db_dir): + return for sfile in os.listdir(db_dir): if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'): song_dbs.append(os.path.join(db_dir, sfile)) From 077337066221ceaec3ce98a753bc753b8f00633b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Tue, 15 Mar 2011 16:38:16 +0200 Subject: [PATCH 3/6] Fix for #65 --- openlp/core/ui/servicemanager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index fa2bc50f5..b43463d32 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -556,6 +556,13 @@ class ServiceManager(QtGui.QWidget): log.exception(u'File contains no service data') except (IOError, NameError): log.exception(u'Problem loading service file %s' % fileName) + except zipfile.BadZipfile: + log.exception(u'Service file is corrupt: %s' % fileName) + QtGui.QMessageBox.information(self, + translate('OpenLP.ServiceManager', 'File Is Corrupt'), + translate('OpenLP.ServiceManager', 'This service file is ' + 'either corrupt or is not an OpenLP 2 service file.')) + return finally: if fileTo: fileTo.close() From b502ad549c022fc66e13f194f7eac0f0431a0b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Wed, 16 Mar 2011 09:55:08 +0200 Subject: [PATCH 4/6] Differentiated error message for zero sized service. --- openlp/core/ui/servicemanager.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index b43463d32..18b9bf8a2 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -557,11 +557,19 @@ class ServiceManager(QtGui.QWidget): except (IOError, NameError): log.exception(u'Problem loading service file %s' % fileName) except zipfile.BadZipfile: - log.exception(u'Service file is corrupt: %s' % fileName) - QtGui.QMessageBox.information(self, - translate('OpenLP.ServiceManager', 'File Is Corrupt'), - translate('OpenLP.ServiceManager', 'This service file is ' - 'either corrupt or is not an OpenLP 2 service file.')) + if os.path.getsize(fileName) == 0: + log.exception(u'Service file is zero sized: %s' % fileName) + QtGui.QMessageBox.information(self, + translate('OpenLP.ServiceManager', 'File Is Empty'), + translate('OpenLP.ServiceManager', 'This service file is ' + 'zero size and does not contain any data.')) + else: + log.exception(u'Service file is cannot be extracted as zip: ' + u'%s' % fileName) + QtGui.QMessageBox.information(self, + translate('OpenLP.ServiceManager', 'File Is Corrupt'), + translate('OpenLP.ServiceManager', 'This service file is ' + 'either corrupt or is not an OpenLP 2 service file.')) return finally: if fileTo: From f73577d7089657a17e7464637217049196281af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Wed, 30 Mar 2011 21:52:58 +0300 Subject: [PATCH 5/6] Undo --- openlp/core/ui/mainwindow.py | 2 -- openlp/plugins/songs/songsplugin.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 8d5db87e5..38775d68e 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -694,8 +694,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): plugin.firstTime() Receiver.send_message(u'openlp_process_events') temp_dir = os.path.join(unicode(gettempdir()), u'openlp') - if not os.path.isdir(temp_dir): - return for filename in os.listdir(temp_dir): os.remove(os.path.join(temp_dir, filename)) os.removedirs(temp_dir) diff --git a/openlp/plugins/songs/songsplugin.py b/openlp/plugins/songs/songsplugin.py index 8edac12f7..1260a832b 100644 --- a/openlp/plugins/songs/songsplugin.py +++ b/openlp/plugins/songs/songsplugin.py @@ -231,8 +231,6 @@ class SongsPlugin(Plugin): """ db_dir = unicode(os.path.join(gettempdir(), u'openlp')) song_dbs = [] - if not os.path.isdir(db_dir): - return for sfile in os.listdir(db_dir): if sfile.startswith(u'songs_') and sfile.endswith(u'.sqlite'): song_dbs.append(os.path.join(db_dir, sfile)) From beffd0c25c266b05a3fb22c68698ec63169d913f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20P=C3=B5ldaru?= Date: Thu, 31 Mar 2011 10:31:08 +0300 Subject: [PATCH 6/6] Text fixes by superfly. --- openlp/core/ui/servicemanager.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d5124ead8..45c7761e9 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -592,16 +592,16 @@ class ServiceManager(QtGui.QWidget): if os.path.getsize(fileName) == 0: log.exception(u'Service file is zero sized: %s' % fileName) QtGui.QMessageBox.information(self, - translate('OpenLP.ServiceManager', 'File Is Empty'), - translate('OpenLP.ServiceManager', 'This service file is ' - 'zero size and does not contain any data.')) + translate('OpenLP.ServiceManager', 'Empty File'), + translate('OpenLP.ServiceManager', 'This service file ' + 'does not contain any data.')) else: log.exception(u'Service file is cannot be extracted as zip: ' u'%s' % fileName) QtGui.QMessageBox.information(self, - translate('OpenLP.ServiceManager', 'File Is Corrupt'), - translate('OpenLP.ServiceManager', 'This service file is ' - 'either corrupt or is not an OpenLP 2 service file.')) + translate('OpenLP.ServiceManager', 'Corrupt File'), + translate('OpenLP.ServiceManager', 'This file is either' + 'corrupt or not an OpenLP 2.0 service file.')) return finally: if fileTo: