mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix cleanup leaks
This commit is contained in:
parent
f951cebc10
commit
a052feda88
|
@ -64,10 +64,20 @@ GBAApp::GBAApp(int& argc, char* argv[], ConfigController* config)
|
|||
if (!m_configController->getQtOption("audioDriver").isNull()) {
|
||||
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();
|
||||
|
||||
while (!m_workerJobs.isEmpty()) {
|
||||
finishJob(m_workerJobs.firstKey());
|
||||
}
|
||||
|
||||
if (m_db) {
|
||||
NoIntroDBDestroy(m_db);
|
||||
}
|
||||
}
|
||||
|
||||
bool GBAApp::event(QEvent* event) {
|
||||
|
@ -177,7 +187,7 @@ bool GBAApp::reloadGameDB() {
|
|||
NoIntroDBDestroy(m_db);
|
||||
}
|
||||
if (db) {
|
||||
GameDBParser* parser = new GameDBParser(db);
|
||||
std::shared_ptr<GameDBParser> parser = std::make_shared<GameDBParser>(db);
|
||||
submitWorkerJob(std::bind(&GameDBParser::parseNoIntroDB, parser));
|
||||
m_db = db;
|
||||
return true;
|
||||
|
|
|
@ -52,7 +52,6 @@ Q_OBJECT
|
|||
|
||||
public:
|
||||
GBAApp(int& argc, char* argv[], ConfigController*);
|
||||
~GBAApp();
|
||||
static GBAApp* app();
|
||||
|
||||
static QString dataDir();
|
||||
|
@ -79,6 +78,7 @@ protected:
|
|||
|
||||
private slots:
|
||||
void finishJob(qint64 jobId);
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
class WorkerJob : public QRunnable {
|
||||
|
|
Loading…
Reference in New Issue