Skip to content

Commit

Permalink
Fixed small bug where the progress bar of the dialog was updated too …
Browse files Browse the repository at this point in the history
…fast for the gui to handle, causing a stack overflow resulting in a crash with a RecursionError
  • Loading branch information
Kurocon committed Apr 26, 2016
1 parent ea5faea commit c9aa94a
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions util/osudb_parser.py
@@ -1,11 +1,5 @@
import hashlib
import os
import re
import logging import logging
import traceback

from util.oce_models import Difficulty2, Songs, Song from util.oce_models import Difficulty2, Songs, Song
from util.osudb_format import OSU_SINGLE, OSU_SHORT, OSU_LONG, OSU_BOOLEAN, OSU_BYTE, OSU_DOUBLE, OSU_INT
from util.osudb_format import read_type from util.osudb_format import read_type


# osu!.db format # osu!.db format
Expand Down Expand Up @@ -210,7 +204,6 @@ def load_osudb(path):
songs = Songs() songs = Songs()


# Try to parse the file as an osu db. # Try to parse the file as an osu db.

# First we have some primitive simple types we can just read in one bunch # First we have some primitive simple types we can just read in one bunch
data = [] data = []
for type in ["Int", "Int", "Boolean", "DateTime", "String", "Int"]: for type in ["Int", "Int", "Boolean", "DateTime", "String", "Int"]:
Expand Down Expand Up @@ -281,10 +274,25 @@ def load_osudb_gui(path, dialog):
# Then, for each beatmap, we need to read the beatmap # Then, for each beatmap, we need to read the beatmap
beatmaps = [] beatmaps = []
dialog.current.emit("Parsing beatmaps...") dialog.current.emit("Parsing beatmaps...")
progress = 0
for _ in range(num_maps): for _ in range(num_maps):
dialog.progress.emit(int((num_done / num_maps) * 100))
beatmaps.append(parse_beatmap(fobj, version)) # Only update the progress bar if there is at least one percent more progress
if progress < int((num_done / num_maps) * 100):
progress = int((num_done / num_maps) * 100)
dialog.progress.emit(progress)

beatmap = parse_beatmap(fobj, version)

# Check if the beatmap was parsed correctly, abourt parsing if not
if None in [beatmap.path, beatmap.name, beatmap.artist, beatmap.mapper, beatmap.difficulty, beatmap.ar,
beatmap.cs, beatmap.hp, beatmap.od, beatmap.hash, beatmap.from_api, beatmap.api_beatmap_id,
beatmap.beatmap_id, beatmap.beatmapset_id]:
log.warn("Parse error detected. Aborting parsing.")
return None

num_done += 1 num_done += 1
beatmaps.append(beatmap)


dialog.current.emit("Loading mapsets into OCE...") dialog.current.emit("Loading mapsets into OCE...")


Expand All @@ -302,6 +310,4 @@ def load_osudb_gui(path, dialog):
s.difficulties = mapset s.difficulties = mapset
songs.add_song(s) songs.add_song(s)


dialog.progress.emit(100)

return songs return songs

0 comments on commit c9aa94a

Please sign in to comment.