From f7987501b94f9b93d24faa3c5833d833c4773023 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 23 May 2010 08:03:28 +0100 Subject: [PATCH] Stop memory growth, improve verse display --- openlp/core/ui/servicemanager.py | 6 +++++- openlp/core/ui/slidecontroller.py | 16 +++++++++------- openlp/plugins/songs/lib/mediaitem.py | 4 +++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c5fa0b73c..df127c85c 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -711,6 +711,10 @@ class ServiceManager(QtGui.QWidget): self.regenerateServiceItems() def regenerateServiceItems(self): + """ + Rebuild the service list as things have changed and a + repaint is the easiest way to do this. + """ #force reset of renderer as theme data has changed self.parent.RenderManager.themedata = None if self.serviceItems: @@ -963,4 +967,4 @@ class ServiceManager(QtGui.QWidget): data_item[u'notes'] = unicode(service_item.notes) data_item[u'selected'] = (item == curitem) data.append(data_item) - Receiver.send_message(u'servicemanager_list_response', data) \ No newline at end of file + Receiver.send_message(u'servicemanager_list_response', data) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index e614205fe..a2bd68e13 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -516,6 +516,9 @@ class SlideController(QtGui.QWidget): #Set pointing cursor when we have somthing to point at self.PreviewListWidget.setCursor(QtCore.Qt.PointingHandCursor) before = time.time() + #Clear the old serviceItem cache to release memory + if self.serviceItem: + self.serviceItem.cache = [] self.serviceItem = serviceItem self.PreviewListWidget.clear() self.PreviewListWidget.setRowCount(0) @@ -531,8 +534,7 @@ class SlideController(QtGui.QWidget): slideHeight = 0 #It is a based Text Render if self.serviceItem.is_text(): - if frame[u'verseTag'] is not None: - #only load the slot once + if frame[u'verseTag']: bits = frame[u'verseTag'].split(u':') tag = None #If verse handle verse number else tag only @@ -545,13 +547,13 @@ class SlideController(QtGui.QWidget): tag = bits[0] tag1 = tag row = bits[0][0:1] - if self.isLive: - if tag1 not in self.slideList: - self.slideList[tag1] = framenumber - self.SongMenu.menu().addAction(self.trUtf8(u'%s'%tag1), - self.onSongBarHandler) else: row += 1 + if self.isLive and frame[u'verseTag'] is not None: + if tag1 not in self.slideList: + self.slideList[tag1] = framenumber + self.SongMenu.menu().addAction(self.trUtf8(u'%s'%tag1), + self.onSongBarHandler) item.setText(frame[u'text']) else: label = QtGui.QLabel() diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 0a2d29b14..2bf72e9b9 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -323,7 +323,9 @@ class SongMediaItem(MediaManagerItem): #no verse list or only 1 space (in error) if not song.verse_order or not song.verse_order.strip(): for verse in verseList: - service_item.add_from_text(verse[1][:30], unicode(verse[1])) + verseTag = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) + service_item.add_from_text(\ + verse[1][:30], unicode(verse[1]), verseTag) else: #Loop through the verse list and expand the song accordingly. for order in song.verse_order.upper().split(u' '):