docker: Change Settings to single owner

We change DockerSettings to have a single owner.
Since DockerDevices are destroyed after the plugin
is unloaded, we have to make sure to remove the
settings from devices during plugin teardown.

For this we store a list of created devices in
the factory, and call their shutdown function when
the plugin unloads.

Change-Id: Ic9c7d8ad9437c48d68f20c9a8f8ad7449b3cb972
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-07-04 14:24:51 +02:00
parent 4d72cb55ba
commit 15c7f08e4a
7 changed files with 67 additions and 32 deletions

View File

@@ -33,6 +33,8 @@
#include <utils/aspects.h>
#include <QMutex>
namespace Docker {
namespace Internal {
@@ -58,10 +60,12 @@ public:
using Ptr = QSharedPointer<DockerDevice>;
using ConstPtr = QSharedPointer<const DockerDevice>;
explicit DockerDevice(QSharedPointer<DockerSettings> settings, const DockerDeviceData &data);
explicit DockerDevice(DockerSettings *settings, const DockerDeviceData &data);
~DockerDevice();
static Ptr create(QSharedPointer<DockerSettings> settings, const DockerDeviceData &data) { return Ptr(new DockerDevice(settings, data)); }
void shutdown();
static Ptr create(DockerSettings *settings, const DockerDeviceData &data) { return Ptr(new DockerDevice(settings, data)); }
ProjectExplorer::IDeviceWidget *createWidget() override;
QList<ProjectExplorer::Task> validate() const override;
@@ -135,7 +139,13 @@ private:
class DockerDeviceFactory final : public ProjectExplorer::IDeviceFactory
{
public:
DockerDeviceFactory(QSharedPointer<DockerSettings> settings);
DockerDeviceFactory(DockerSettings *settings);
void shutdownExistingDevices();
private:
QMutex m_deviceListMutex;
std::vector<QWeakPointer<DockerDevice> > m_existingDevices;
};
} // Internal