Push more tag saving off the GUI thread.

Update issue #542
This commit is contained in:
John Maguire 2010-08-02 14:22:05 +00:00
parent 8166a50b2a
commit f45ec1a43e
2 changed files with 19 additions and 4 deletions

View File

@ -21,6 +21,7 @@
#include "core/globalshortcuts.h"
#include "core/mac_startup.h"
#include "core/mergedproxymodel.h"
#include "core/modelfuturewatcher.h"
#include "core/player.h"
#include "core/songloader.h"
#include "core/stylesheetloader.h"
@ -1111,13 +1112,23 @@ void MainWindow::RenumberTracks() {
if (song.IsEditable()) {
song.set_track(track);
song.Save();
playlists_->current()->item_at(row)->Reload();
QFuture<bool> future = song.BackgroundSave();
ModelFutureWatcher<bool>* watcher = new ModelFutureWatcher<bool>(index, this);
watcher->setFuture(future);
connect(watcher, SIGNAL(finished()), SLOT(SongSaveComplete()));
}
track++;
}
}
void MainWindow::SongSaveComplete() {
ModelFutureWatcher<bool>* watcher = static_cast<ModelFutureWatcher<bool>*>(sender());
watcher->deleteLater();
if (watcher->index().isValid()) {
playlists_->current()->item_at(watcher->index().row())->Reload();
}
}
void MainWindow::SelectionSetValue() {
Playlist::Column column = (Playlist::Column)playlist_menu_index_.column();
QVariant column_value = playlists_->current()->data(playlist_menu_index_);
@ -1131,8 +1142,10 @@ void MainWindow::SelectionSetValue() {
Song song = playlists_->current()->item_at(row)->Metadata();
if(Playlist::set_column_value(song, column, column_value)) {
song.Save();
playlists_->current()->item_at(row)->Reload();
QFuture<bool> future = song.BackgroundSave();
ModelFutureWatcher<bool>* watcher = new ModelFutureWatcher<bool>(index, this);
watcher->setFuture(future);
connect(watcher, SIGNAL(finished()), SLOT(SongSaveComplete()));
}
}
}

View File

@ -167,6 +167,8 @@ class MainWindow : public QMainWindow, public PlatformInterface {
void NowPlayingWidgetPositionChanged(bool above_status_bar);
void SongSaveComplete();
private:
void SaveGeometry();
void AddFilesToPlaylist(bool clear_first, const QList<QUrl>& urls);