openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #19536
[Merge] lp:~phill-ridout/openlp/1114457_2.0 into lp:openlp/2.0
Phill has proposed merging lp:~phill-ridout/openlp/1114457_2.0 into lp:openlp/2.0.
Requested reviews:
Raoul Snyman (raoul-snyman)
Related bugs:
Bug #1114457 in OpenLP: "Easy Worship importer progress bar is out"
https://bugs.launchpad.net/openlp/+bug/1114457
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/1114457_2.0/+merge/149420
Fixes 1114457 by counting the records. Trunk version to follow once Bug #1116528 has been fixed
--
https://code.launchpad.net/~phill-ridout/openlp/1114457_2.0/+merge/149420
Your team OpenLP Core is subscribed to branch lp:openlp/2.0.
=== modified file 'openlp/plugins/songs/lib/ewimport.py'
--- openlp/plugins/songs/lib/ewimport.py 2013-02-03 21:00:22 +0000
+++ openlp/plugins/songs/lib/ewimport.py 2013-02-19 22:00:36 +0000
@@ -108,10 +108,6 @@
self.encoding = retrieve_windows_encoding(self.encoding)
if not self.encoding:
return
- # There does not appear to be a _reliable_ way of getting the number
- # of songs/records, so let's use file blocks for measuring progress.
- total_blocks = (db_size - header_size) / (block_size * 1024)
- self.importWizard.progressBar.setMaximum(total_blocks)
# Read the field description information
db_file.seek(120)
field_info = db_file.read(num_fields * 2)
@@ -138,12 +134,24 @@
except IndexError:
# This is the wrong table
success = False
- # Loop through each block of the file
+ # There does not appear to be a _reliable_ way of getting the number
+ # of songs/records, so loop through the file blocks and total the
+ # number of records. Store the information in a list so we dont have
+ # to do all this again.
cur_block = first_block
+ total_count = 0
+ block_list = []
while cur_block != 0 and success:
- db_file.seek(header_size + ((cur_block - 1) * 1024 * block_size))
+ cur_block_pos = header_size + ((cur_block - 1) * 1024 * block_size)
+ db_file.seek(cur_block_pos)
cur_block, rec_count = struct.unpack('<h2xh', db_file.read(6))
rec_count = (rec_count + record_size) / record_size
+ block_list.append((cur_block_pos, rec_count))
+ total_count += rec_count
+ self.importWizard.progressBar.setMaximum(total_count)
+ for block in block_list:
+ cur_block_pos, rec_count = block
+ db_file.seek(cur_block_pos + 6)
# Loop through each record within the current block
for i in range(rec_count):
if self.stopImportFlag:
Follow ups