CompilerExplorer: Un-static NetworkAccessManager

We have seen crashes on Windows when the static network access manager
is deleted (with a "dev" version of Qt). Out of an abundance of caution this
patch changes the Network access manager to be owned by the actual
settings object.

Change-Id: I999a15d99315019b3e5f4ed330a4ac058849f066
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2023-12-14 11:23:25 +01:00
parent 21c868604e
commit d6b27f372b
2 changed files with 3 additions and 6 deletions

View File

@@ -306,8 +306,7 @@ CompilerExplorerSettings::CompilerExplorerSettings()
{
setAutoApply(false);
setSettingsKey("CompilerExplorer");
static QNetworkAccessManager networkManager;
m_networkAccessManager = &networkManager;
m_networkAccessManager = std::make_unique<QNetworkAccessManager>();
compilerExplorerUrl.setSettingsKey("CompilerExplorerUrl");
compilerExplorerUrl.setLabelText(Tr::tr("Compiler Explorer URL:"));

View File

@@ -40,13 +40,11 @@ public:
Api::Config apiConfig() const
{
return Api::Config(m_networkAccessManager, compilerExplorerUrl());
return Api::Config(m_networkAccessManager.get(), compilerExplorerUrl());
}
QNetworkAccessManager *networkAccessManager() const { return m_networkAccessManager; }
private:
QNetworkAccessManager *m_networkAccessManager{nullptr};
std::unique_ptr<QNetworkAccessManager> m_networkAccessManager;
};
class SourceSettings : public Utils::AspectContainer,