Commit 7d066a15 authored by camilo higuita's avatar camilo higuita

more performance issues

parent ac74ec62
......@@ -26,6 +26,13 @@ using namespace BAE;
CollectionDB::CollectionDB(QObject *parent) : QObject(parent)
{
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [this]()
{
this->m_db.close();
this->instance->deleteLater();
this->instance = nullptr;
});
this->name = QUuid::createUuid().toString();
if(!BAE::fileExists(BAE::CollectionDBPath + BAE::DBName))
......@@ -45,8 +52,6 @@ CollectionDB::CollectionDB(QObject *parent) : QObject(parent)
CollectionDB::~CollectionDB()
{
qDebug()<< "DELETING COLLECTIONDB SINGLETON";
this->m_db.close();
delete this->instance;
}
CollectionDB *CollectionDB::instance = nullptr;
......@@ -65,6 +70,10 @@ CollectionDB *CollectionDB::getInstance()
}
}
void CollectionDB::deleteInstance()
{
delete this;
}
void CollectionDB::prepareCollectionDB()
{
......
This diff is collapsed.
......@@ -7,10 +7,11 @@ AlbumsModel::AlbumsModel(QObject *parent) : BaseList(parent)
{
this->db = CollectionDB::getInstance();
connect(this, &AlbumsModel::queryChanged, this, &AlbumsModel::setList);
QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=]()
{
pool.waitForDone();
});
}
AlbumsModel::~AlbumsModel()
{
}
FMH::MODEL_LIST AlbumsModel::items() const
......@@ -132,8 +133,6 @@ void AlbumsModel::runBrain()
watcher->deleteLater();
});
auto func = [=]()
{
QList<PULPO::REQUEST> requests;
......@@ -192,16 +191,28 @@ void AlbumsModel::runBrain()
Pulpo pulpo;
QEventLoop loop;
QObject::connect(&pulpo, &Pulpo::finished, &loop, &QEventLoop::quit);
bool stop = false;
// QObject::connect(qApp, &QCoreApplication::aboutToQuit, [&]()
// {
// stop = true;
// loop.quit();
// });
QObject::connect(this, &AlbumsModel::destroyed, [&]()
{
stop = true;
loop.quit();
});
for(auto i = 0; i < requests.size(); i++)
{
pulpo.request(requests.at(i));
loop.exec();
if(stop)
return;
}
};
QFuture<void> t1 = QtConcurrent::run(&pool, func);
QFuture<void> t1 = QtConcurrent::run(func);
watcher->setFuture(t1);
}
......
......@@ -3,7 +3,6 @@
#include <QObject>
#include "models/baselist.h"
#include <QThreadPool>
class CollectionDB;
class AlbumsModel : public BaseList
......@@ -30,6 +29,7 @@ public:
Q_ENUM(QUERY)
explicit AlbumsModel(QObject *parent = nullptr);
~AlbumsModel();
FMH::MODEL_LIST items() const override;
......@@ -50,7 +50,6 @@ private:
void runBrain();
void updateArtwork(const int index, const QString &artwork);
QThreadPool pool;
signals:
void queryChanged();
......
......@@ -56,50 +56,6 @@ vvave::vvave(QObject *parent) : QObject(parent)
vvave::~vvave() {}
void vvave::runBrain()
{
QFutureWatcher<void> *watcher = new QFutureWatcher<void>;
QObject::connect(watcher, &QFutureWatcher<void>::finished, [=]()
{
watcher->deleteLater();
emit this->refreshAlbums();
});
// QObject::connect(qApp, &QCoreApplication::aboutToQuit, [=]()
// {
// if(watcher != nullptr)
// watcher->future().waitForFinished();
// });
// auto func = [=]()
// {
// the album artworks package
// BRAIN::PACKAGE albumPackage;
// albumPackage.ontology = PULPO::ONTOLOGY::ALBUM;
// albumPackage.info = PULPO::INFO::ARTWORK;
// albumPackage.callback = [=]()
// {
// emit this->refreshAlbums();
// };
// BRAIN::PACKAGE artistPackage;
// artistPackage.ontology = PULPO::ONTOLOGY::ARTIST;
// artistPackage.info = PULPO::INFO::ARTWORK;
// artistPackage.callback = [=]()
// {
// emit this->refreshArtists();
// };
// BRAIN::synapse(BRAIN::PACKAGES() << albumPackage /*<< artistPackage*/);
// };
// QFuture<void> t1 = QtConcurrent::run(func);
// watcher->setFuture(t1);
}
void vvave::checkCollection(const QStringList &paths, std::function<void(uint)> cb)
{
QFutureWatcher<uint> *watcher = new QFutureWatcher<uint>;
......@@ -150,7 +106,6 @@ void vvave::scanDir(const QStringList &paths)
this->checkCollection(paths, [=](uint size)
{
emit this->refreshTables(size);
// this->runBrain();
});
}
......
......@@ -14,7 +14,6 @@ private:
Notify *notify;
CollectionDB *db;
void checkCollection(const QStringList &paths = BAE::defaultSources, std::function<void (uint)> cb = nullptr);
void runBrain();
public:
explicit vvave(QObject *parent = nullptr);
......
Markdown is supported
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