Safely close database connections and delete backends
Also fix NewClosure leak caused by disconnected object signals
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "collection/sqlrow.h"
|
||||
#include "playlistitem.h"
|
||||
|
||||
class QThread;
|
||||
class Application;
|
||||
class Database;
|
||||
|
||||
@@ -47,6 +48,7 @@ class PlaylistBackend : public QObject {
|
||||
|
||||
public:
|
||||
Q_INVOKABLE PlaylistBackend(Application *app, QObject *parent = nullptr);
|
||||
~PlaylistBackend();
|
||||
|
||||
struct Playlist {
|
||||
Playlist() : id(-1), favorite(false), last_played(0) {}
|
||||
@@ -62,6 +64,9 @@ class PlaylistBackend : public QObject {
|
||||
|
||||
static const int kSongTableJoins;
|
||||
|
||||
void Close();
|
||||
void ExitAsync();
|
||||
|
||||
PlaylistList GetAllPlaylists();
|
||||
PlaylistList GetAllOpenPlaylists();
|
||||
PlaylistList GetAllFavoritePlaylists();
|
||||
@@ -82,8 +87,12 @@ class PlaylistBackend : public QObject {
|
||||
Application *app() const { return app_; }
|
||||
|
||||
public slots:
|
||||
void Exit();
|
||||
void SavePlaylist(int playlist, const PlaylistItemList &items, int last_played);
|
||||
|
||||
signals:
|
||||
void ExitFinished();
|
||||
|
||||
private:
|
||||
struct NewSongFromQueryState {
|
||||
QHash<QString, SongList> cached_cues_;
|
||||
@@ -105,6 +114,7 @@ class PlaylistBackend : public QObject {
|
||||
|
||||
Application *app_;
|
||||
Database *db_;
|
||||
QThread *original_thread_;
|
||||
};
|
||||
|
||||
#endif // PLAYLISTBACKEND_H
|
||||
|
||||
Reference in New Issue
Block a user