NOISSUE Refactor and sanitize MultiMC startup/shutdown

* Always create main window.
* Properly handle netowrk manager - it was created twice, leading to potential crashes.
This commit is contained in:
Petr Mrázek
2016-11-06 21:58:54 +01:00
parent 37cc59c04d
commit 8b952b3870
17 changed files with 116 additions and 144 deletions

View File

@ -7,6 +7,8 @@
#include "multimc_logic_export.h"
#include "QObjectPtr.h"
class QNetworkAccessManager;
class HttpMetaCache;
class BaseVersionList;
@ -22,16 +24,15 @@ class MULTIMC_LOGIC_EXPORT Env
{
friend class MultiMC;
private:
class Private;
Env();
~Env();
public:
static Env& getInstance();
// call when Qt stuff is being torn down
void destroy();
QNetworkAccessManager &qnam() const;
std::shared_ptr<QNetworkAccessManager> qnam();
std::shared_ptr<HttpMetaCache> metacache();
shared_qobject_ptr<HttpMetaCache> metacache();
std::shared_ptr<IIconList> icons();
@ -51,16 +52,11 @@ public:
void registerIconList(std::shared_ptr<IIconList> iconlist);
std::shared_ptr<WonkoIndex> wonkoIndex();
shared_qobject_ptr<WonkoIndex> wonkoIndex();
QString wonkoRootUrl() const { return m_wonkoRootUrl; }
void setWonkoRootUrl(const QString &url) { m_wonkoRootUrl = url; }
QString wonkoRootUrl() const;
void setWonkoRootUrl(const QString &url);
protected:
std::shared_ptr<QNetworkAccessManager> m_qnam;
std::shared_ptr<HttpMetaCache> m_metacache;
std::shared_ptr<IIconList> m_iconlist;
QMap<QString, std::shared_ptr<BaseVersionList>> m_versionLists;
std::shared_ptr<WonkoIndex> m_wonkoIndex;
QString m_wonkoRootUrl;
Private * d;
};