Qt: Fix cleanup leaks

This commit is contained in:
Vicki Pfau 2018-09-03 13:03:14 -07:00
parent f951cebc10
commit a052feda88
2 changed files with 13 additions and 3 deletions

View File

@ -64,10 +64,20 @@ GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config)
if (!m_configController->getQtOption("audioDriver").isNull()) { if (!m_configController->getQtOption("audioDriver").isNull()) {
AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController->getQtOption("audioDriver").toInt())); AudioProcessor::setDriver(static_cast<AudioProcessor::Driver>(m_configController->getQtOption("audioDriver").toInt()));
} }
connect(this, &GBAApp::aboutToQuit, this, &GBAApp::cleanup);
} }
GBAApp::~GBAApp() { void GBAApp::cleanup() {
m_workerThreads.waitForDone(); m_workerThreads.waitForDone();
while (!m_workerJobs.isEmpty()) {
finishJob(m_workerJobs.firstKey());
}
if (m_db) {
NoIntroDBDestroy(m_db);
}
} }
bool GBAApp::event(QEvent* event) { bool GBAApp::event(QEvent* event) {
@ -177,7 +187,7 @@ bool GBAApp::reloadGameDB() {
NoIntroDBDestroy(m_db); NoIntroDBDestroy(m_db);
} }
if (db) { if (db) {
GameDBParser* parser = new GameDBParser(db); std::shared_ptr<GameDBParser> parser = std::make_shared<GameDBParser>(db);
submitWorkerJob(std::bind(&GameDBParser::parseNoIntroDB, parser)); submitWorkerJob(std::bind(&GameDBParser::parseNoIntroDB, parser));
m_db = db; m_db = db;
return true; return true;

View File

@ -52,7 +52,6 @@ Q_OBJECT
public: public:
GBAApp(int& argc, char* argv[], ConfigController*); GBAApp(int& argc, char* argv[], ConfigController*);
~GBAApp();
static GBAApp* app(); static GBAApp* app();
static QString dataDir(); static QString dataDir();
@ -79,6 +78,7 @@ protected:
private slots: private slots:
void finishJob(qint64 jobId); void finishJob(qint64 jobId);
void cleanup();
private: private:
class WorkerJob : public QRunnable { class WorkerJob : public QRunnable {