[banshee/stable-2.4] DapSource: Flush pending changes when disposing too (bgo#666696)
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/stable-2.4] DapSource: Flush pending changes when disposing too (bgo#666696)
- Date: Sun, 20 May 2012 17:26:55 +0000 (UTC)
commit 5402cfa78877a186e49612937e9415bcffb81414
Author: Andres G. Aragoneses <knocte gmail com>
Date: Tue Dec 27 23:07:28 2011 +0000
DapSource: Flush pending changes when disposing too (bgo#666696)
The code to flush pending sync changes was only being called when the
user chose to eject the device. However this should not be the only
operation that yields the flush, as quitting the media player is not
meant to discard automatically the changes that a user may have done to
a Dap source.
Ejecting a device causes the corresponding DapSource to be disposed
later, so we need to make sure we don't do the flush twice, especially
as by the time DapSource is disposed after ejecting, the volume is
already unmounted.
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs b/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
index e5e23e7..d4961a3 100644
--- a/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
+++ b/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
@@ -54,6 +54,7 @@ namespace Banshee.Dap
{
public abstract class DapSource : RemovableSource, IDisposable
{
+ private bool flushed = false;
private DapSync sync;
private DapInfoBar dap_info_bar;
private Page page;
@@ -97,6 +98,8 @@ namespace Banshee.Dap
public override void Dispose ()
{
+ Flush ();
+
PurgeTemporaryPlaylists ();
PurgeTracks ();
@@ -312,10 +315,18 @@ namespace Banshee.Dap
protected override void Eject ()
{
- if (!Sync.Enabled) {
- // If sync isn't enabled, then make sure we've written saved our playlists
- // Track transfers happen immediately, but playlists saves don't
- SyncPlaylists ();
+ Flush ();
+ }
+
+ private void Flush ()
+ {
+ if (!flushed) {
+ flushed = true;
+ if (!Sync.Enabled) {
+ // If sync isn't enabled, then make sure we've written saved our playlists
+ // Track transfers happen immediately, but playlists saves don't
+ SyncPlaylists ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]