Docker: Use a optional<Environment> to handle the non-fetched state

Change-Id: I93ef9da6c9c7731b28f9d6fab6413ce9c4f428b4
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-01-26 15:22:23 +01:00
parent dab859e776
commit 040ef3b7d3

View File

@@ -198,7 +198,7 @@ public:
QString m_container;
Environment m_cachedEnviroment;
std::optional<Environment> m_cachedEnviroment;
bool m_isShutdown = false;
DockerDeviceFileAccess m_fileAccess{this};
};
@@ -500,7 +500,7 @@ void DockerDevicePrivate::stopCurrentContainer()
proc.runBlocking();
m_cachedEnviroment.clear();
m_cachedEnviroment.reset();
}
bool DockerDevicePrivate::prepareForBuild(const Target *target)
@@ -1137,11 +1137,11 @@ bool DockerDevicePrivate::addTemporaryMount(const FilePath &path, const FilePath
Environment DockerDevicePrivate::environment()
{
if (!m_cachedEnviroment.hasChanges())
if (!m_cachedEnviroment)
fetchSystemEnviroment();
QTC_CHECK(m_cachedEnviroment.hasChanges());
return m_cachedEnviroment;
QTC_ASSERT(m_cachedEnviroment, return {});
return m_cachedEnviroment.value();
}
void DockerDevicePrivate::shutdown()