Commit 82bf0a85 authored by Matěj Laitl's avatar Matěj Laitl
Browse files

Definitely fix the caching bug (mis-attributed to Collection Browser)

Local Collection wasn't simply emitting updated() enough.

Fix docs when at it to prevent such bugs in future.

BUG: 262504
FIXED-IN: 2.8
parent acf7cfab
......@@ -63,8 +63,8 @@ VERSION 2.8-Beta 1
not to fool users.
BUGFIXES:
* Definitely fix a bug where Local Collection wouldn't update in browser. (BR 262504)
* Fix crashed caused by race conditions at the end of the track scanning. (BR 319835)
* Make Collection Browser update listing correctly when metadata change. (BR 262504)
* Fix crash when disabling the Free Music Charts script. (BR 321329)
* Albums having same name but different album artist won't be mixed together on the
playlist if sorting by album is enabled.
......
......@@ -78,21 +78,28 @@ class DatabaseCollection : public Collections::Collection
virtual QStringList collectionFolders() const;
virtual void setCollectionFolders( const QStringList &folders );
/** Call this function to prevent the collection updated signal emitted.
* This function can be called in preparation of larger updates.
/**
* Call this function to prevent the collection updated signal emitted.
* This function can be called in preparation of larger updates.
*/
virtual void blockUpdatedSignal();
void blockUpdatedSignal();
/** Unblocks one blockUpdatedSignal call. */
virtual void unblockUpdatedSignal();
/**
* Unblocks one blockUpdatedSignal call. If collectionUpdated() has been called,
* when the update was blocked, update() will be emitted here.
*/
void unblockUpdatedSignal();
/**
* Emit updated if the signal. If it is blocked by blockUpdatedSignal(), it will
* be postponed until unblockUpdatedSignal() is called, but never discarded.
*/
void collectionUpdated();
virtual bool hasCapabilityInterface( Capabilities::Capability::Type type ) const;
virtual Capabilities::Capability* createCapabilityInterface( Capabilities::Capability::Type type );
public slots:
/** Emit updated if the signal is not blocked by blockUpdatedSignal */
virtual void collectionUpdated();
/** Dumps the complete database content.
* The content of all Amarok tables is dumped in a couple of files
* in the users homedirectory.
......
......@@ -814,30 +814,38 @@ SqlRegistry::commitDirtyTracks()
// -- notify all observers
foreach( Meta::SqlYearPtr year, dirtyYears )
{
// this means that a new year was added to track or an old removed (or both),
// Collection docs says we need to emit updated() in this case. Ditto below.
m_collectionChanged = true;
year->invalidateCache();
year->notifyObservers();
}
foreach( Meta::SqlGenrePtr genre, dirtyGenres )
{
m_collectionChanged = true;
genre->invalidateCache();
genre->notifyObservers();
}
foreach( Meta::SqlAlbumPtr album, dirtyAlbums )
{
m_collectionChanged = true;
album->invalidateCache();
album->notifyObservers();
}
foreach( Meta::SqlTrackPtr track, dirtyTracks )
{
// if only track changes, no need to emit updated() from here
track->notifyObservers();
}
foreach( Meta::SqlArtistPtr artist, dirtyArtists )
{
m_collectionChanged = true;
artist->invalidateCache();
artist->notifyObservers();
}
foreach( Meta::SqlComposerPtr composer, dirtyComposers )
{
m_collectionChanged = true;
composer->invalidateCache();
composer->notifyObservers();
}
......
......@@ -163,12 +163,12 @@ class IpodCollection : public Collections::Collection, public Meta::Observer
*/
void slotShowConfigureDialog( const QString &errorMessage = QString() );
private slots:
/**
* Overridden to update m_lastUpdated timestamp
* Update m_lastUpdated timestamp and emit updated()
*/
virtual void collectionUpdated();
void collectionUpdated();
private slots:
/**
* Tries to initialize iPod, read the database, add tracks. (Re)shows the
* configuration dialog with info about initialization.
......
......@@ -135,6 +135,7 @@ class MEDIADEVICECOLLECTION_EXPORT MediaDeviceCollection : public Collections::C
virtual QAction *ejectAction() const;
QSharedPointer<MemoryCollection> memoryCollection() const { return m_mc; }
void collectionUpdated() { emit updated(); }
signals:
void collectionReady( Collections::Collection* );
......
......@@ -173,12 +173,12 @@ class UmsCollection : public Collection, public Meta::Observer
void slotTrackAdded( KUrl trackLocation );
void slotTrackRemoved( const Meta::TrackPtr &track );
private slots:
/**
* overridden to update m_lastUpdated timestamp
* Update m_lastUpdated timestamp and emit updated()
*/
virtual void collectionUpdated();
void collectionUpdated();
private slots:
void slotParseTracks();
void slotParseActionTriggered();
void slotConfigure();
......
......@@ -134,20 +134,36 @@ namespace Collections
*/
virtual bool isOrganizable() const;
public slots:
virtual void collectionUpdated() { emit updated(); }
signals:
/**
* Once you register a collection with CollectionManager, this signal is the
* only way to safely destroy it. CollectionManger will remove this collection
* from the list of active ones and will destroy this collection after some
* time.
*/
void remove();
/**
* This signal is sent when the collection has changed.
* This signal is sent when the collection more than can be detected by
* Meta::metaDataChanged.
* This is e.g. a new song was added, an old one removed, new device added, ...
* This signal must be emitted when the collection contents has changed
* significantly.
*
* More specifically, you must emit this signal (only) in such situations:
* a) the set of entities (tracks, albums, years, ...) in this collection has
* changed: a track was added, album is renamed, year was removed...
* b) the relationship between the entities has changed: the track changed
* album, album is no longer associated to an album artist and bacame a
* compilation, an alum changed its year...
*
* You should not emit this signal when some minor data of an entity change,
* for example when a track comment changes, etc.
*
* Also note there are ::notifyObservers() methods of various entities.
* ::notifyObservers() and Collection::updated() are perpendicular and
* responsibility to call one of these may and may not mean need to call the
* other.
*
* Specifically this means that previous done searches can no longer
* be considered valid.
* This signal spedifically this means that previous done searches can no
* longer be considered valid.
*/
void updated();
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment