Merge session.commit() calls
This commit is contained in:
commit
feb09db3d7
@ -197,6 +197,11 @@ class PlaylistTrack:
|
||||
milliseconds=update_graph_at_ms
|
||||
)
|
||||
|
||||
# Calculate time fade_graph should start updating
|
||||
if self.fade_at:
|
||||
update_graph_at_ms = max(0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1)
|
||||
self.fade_graph_start_updates = now + timedelta(milliseconds=update_graph_at_ms)
|
||||
|
||||
|
||||
class AddFadeCurve(QObject):
|
||||
"""
|
||||
|
||||
@ -465,6 +465,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
record = settings["active_tab"]
|
||||
record.update(session, {"f_int": self.tabPlaylist.currentIndex()})
|
||||
|
||||
session.commit()
|
||||
|
||||
event.accept()
|
||||
|
||||
def close_playlist_tab(self) -> bool:
|
||||
@ -642,9 +644,11 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
):
|
||||
if self.close_playlist_tab():
|
||||
playlist.delete(session)
|
||||
session.commit()
|
||||
else:
|
||||
log.error("Failed to retrieve playlist")
|
||||
|
||||
|
||||
def download_played_tracks(self) -> None:
|
||||
"""Download a CSV of played tracks"""
|
||||
|
||||
@ -886,6 +890,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
source_model=self.active_proxy_model(),
|
||||
)
|
||||
dlg.exec()
|
||||
session.commit()
|
||||
|
||||
def load_last_playlists(self) -> None:
|
||||
"""Load the playlists that were open when the last session closed"""
|
||||
@ -907,6 +912,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
# window. To avoid possible duplicate tab entries, we null
|
||||
# them all out now.
|
||||
Playlists.clear_tabs(session, playlist_ids)
|
||||
session.commit()
|
||||
|
||||
def lookup_row_in_songfacts(self) -> None:
|
||||
"""
|
||||
@ -1104,10 +1110,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
log.error("musicmuster.play_next(): no path for next track")
|
||||
return
|
||||
|
||||
# TODO temporary measure to help isolate issue #223
|
||||
self.timer10.stop()
|
||||
self.show_status_message("10ms timer disabled", 0)
|
||||
|
||||
# If there's currently a track playing, fade it.
|
||||
self.stop_playing(fade=True)
|
||||
|
||||
@ -1202,6 +1204,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
playlist.rename(session, new_name)
|
||||
idx = self.tabBar.currentIndex()
|
||||
self.tabBar.setTabText(idx, new_name)
|
||||
session.commit()
|
||||
|
||||
def resume(self) -> None:
|
||||
"""
|
||||
@ -1264,6 +1267,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
Playlists.save_as_template(
|
||||
session, self.active_tab().playlist_id, template_name
|
||||
)
|
||||
session.commit()
|
||||
helpers.show_OK(self, "Template", "Template saved")
|
||||
|
||||
def search_playlist(self) -> None:
|
||||
@ -1567,11 +1571,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
time_to_fade = track_sequence.now.fade_at - playtime
|
||||
time_to_silence = track_sequence.now.silence_at - playtime
|
||||
|
||||
# TODO working on issue #223
|
||||
if playtime > 10000 and not self.timer10.isActive():
|
||||
self.timer10.start(10)
|
||||
self.show_status_message("10ms timer enabled", 0)
|
||||
|
||||
# Elapsed time
|
||||
self.label_elapsed_timer.setText(
|
||||
helpers.ms_to_mmss(playtime)
|
||||
|
||||
@ -141,6 +141,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
PlaylistRows.fixup_rownumbers(session, playlist_id)
|
||||
# Populate self.playlist_rows
|
||||
self.refresh_data(session)
|
||||
session.commit()
|
||||
self.update_track_times()
|
||||
|
||||
def __repr__(self) -> str:
|
||||
@ -333,6 +334,8 @@ class PlaylistModel(QAbstractTableModel):
|
||||
if next_row is not None:
|
||||
self.set_next_row(next_row)
|
||||
|
||||
session.commit()
|
||||
|
||||
def data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
|
||||
"""Return data to view"""
|
||||
|
||||
@ -395,6 +398,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
PlaylistRows.delete_row(session, self.playlist_id, row_number)
|
||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||
self.refresh_data(session)
|
||||
session.commit()
|
||||
super().endRemoveRows()
|
||||
|
||||
self.reset_track_sequence_row_numbers()
|
||||
@ -771,6 +775,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
note=note,
|
||||
track_id=track_id,
|
||||
)
|
||||
session.commit()
|
||||
|
||||
self.refresh_data(session)
|
||||
super().endInsertRows()
|
||||
@ -836,6 +841,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
if not plr:
|
||||
return
|
||||
plr.played = False
|
||||
session.commit()
|
||||
self.refresh_row(session, row_number)
|
||||
|
||||
self.invalidate_rows(row_numbers)
|
||||
@ -895,6 +901,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
|
||||
with db.Session() as session:
|
||||
PlaylistRows.update_plr_rownumbers(session, self.playlist_id, sqla_map)
|
||||
session.commit()
|
||||
# Update playlist_rows
|
||||
self.refresh_data(session)
|
||||
|
||||
@ -955,6 +962,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
# moved.
|
||||
PlaylistRows.fixup_rownumbers(session, self.playlist_id)
|
||||
self.refresh_data(session)
|
||||
session.commit()
|
||||
|
||||
# Reset of model must come after session has been closed
|
||||
self.reset_track_sequence_row_numbers()
|
||||
@ -979,6 +987,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
plr.note += "\n" + note
|
||||
else:
|
||||
plr.note = note
|
||||
session.commit()
|
||||
|
||||
# Carry out the move outside of the session context to ensure
|
||||
# database updated with any note change
|
||||
@ -1085,6 +1094,7 @@ class PlaylistModel(QAbstractTableModel):
|
||||
plr = session.get(PlaylistRows, self.playlist_rows[row_number].plrid)
|
||||
if plr:
|
||||
plr.track_id = None
|
||||
session.commit()
|
||||
self.refresh_row(session, row_number)
|
||||
self.invalidate_row(row_number)
|
||||
|
||||
@ -1285,8 +1295,8 @@ class PlaylistModel(QAbstractTableModel):
|
||||
if column == HEADER_NOTES_COLUMN:
|
||||
plr.note = str(value)
|
||||
|
||||
# Flush changes before refreshing data
|
||||
session.flush()
|
||||
# commit changes before refreshing data
|
||||
session.commit()
|
||||
self.refresh_row(session, row_number)
|
||||
self.dataChanged.emit(index, index, [Qt.ItemDataRole.DisplayRole, role])
|
||||
return True
|
||||
|
||||
@ -346,6 +346,7 @@ class PlaylistTab(QTableView):
|
||||
add_to_header=True,
|
||||
)
|
||||
dlg.exec()
|
||||
session.commit()
|
||||
|
||||
def _audactity_command(self, cmd: str) -> bool:
|
||||
"""
|
||||
@ -543,6 +544,7 @@ class PlaylistTab(QTableView):
|
||||
attr_name = f"playlist_col_{column_number}_width"
|
||||
record = Settings.get_int_settings(session, attr_name)
|
||||
record.f_int = self.columnWidth(column_number)
|
||||
session.commit()
|
||||
|
||||
def _context_menu(self, pos):
|
||||
"""Display right-click menu"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user