From 5565a2f85e8b7a4b0e4758b5b6f4d806b964cf94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 18 Apr 2017 16:45:58 +0200 Subject: NOISSUE fix crash because of early destruction of java list load task --- api/logic/java/JavaInstallList.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'api/logic/java/JavaInstallList.cpp') diff --git a/api/logic/java/JavaInstallList.cpp b/api/logic/java/JavaInstallList.cpp index dbf66f5f..44ac861d 100644 --- a/api/logic/java/JavaInstallList.cpp +++ b/api/logic/java/JavaInstallList.cpp @@ -31,7 +31,27 @@ JavaInstallList::JavaInstallList(QObject *parent) : BaseVersionList(parent) shared_qobject_ptr JavaInstallList::getLoadTask() { - return new JavaListLoadTask(this); + load(); + return getCurrentTask(); +} + +shared_qobject_ptr JavaInstallList::getCurrentTask() +{ + if(m_status == Status::InProgress) + { + return m_loadTask; + } + return nullptr; +} + +void JavaInstallList::load() +{ + if(m_status != Status::InProgress) + { + m_status = Status::InProgress; + m_loadTask = new JavaListLoadTask(this); + m_loadTask->start(); + } } const BaseVersionPtr JavaInstallList::at(int i) const @@ -41,7 +61,7 @@ const BaseVersionPtr JavaInstallList::at(int i) const bool JavaInstallList::isLoaded() { - return m_loaded; + return m_status == JavaInstallList::Status::Done; } int JavaInstallList::count() const @@ -87,7 +107,6 @@ void JavaInstallList::updateListData(QList versions) { beginResetModel(); m_vlist = versions; - m_loaded = true; sortVersions(); if(m_vlist.size()) { @@ -95,6 +114,8 @@ void JavaInstallList::updateListData(QList versions) best->recommended = true; } endResetModel(); + m_status = Status::Done; + m_loadTask.reset(); } bool sortJavas(BaseVersionPtr left, BaseVersionPtr right) -- cgit v1.2.3