diff --git a/src/platform/qt/VFileDevice.cpp b/src/platform/qt/VFileDevice.cpp index 331720fa8..c2eff887c 100644 --- a/src/platform/qt/VFileDevice.cpp +++ b/src/platform/qt/VFileDevice.cpp @@ -91,6 +91,10 @@ VFileDevice::VFileDevice(const QString& filename, QIODevice::OpenMode mode, QObj } } +VFileDevice::~VFileDevice() { + close(); +} + void VFileDevice::close() { if (!m_vf) { return; @@ -117,6 +121,13 @@ VFileDevice& VFileDevice::operator=(VFile* vf) { return *this; } +VFile* VFileDevice::take() { + VFile* vf = m_vf; + m_vf = nullptr; + QIODevice::close(); + return vf; +} + qint64 VFileDevice::readData(char* data, qint64 maxSize) { return m_vf->read(m_vf, data, maxSize); } diff --git a/src/platform/qt/VFileDevice.h b/src/platform/qt/VFileDevice.h index 72f3f1379..b230d14ae 100644 --- a/src/platform/qt/VFileDevice.h +++ b/src/platform/qt/VFileDevice.h @@ -20,6 +20,7 @@ Q_OBJECT public: VFileDevice(VFile* vf = nullptr, QObject* parent = nullptr); VFileDevice(const QString&, QIODevice::OpenMode, QObject* parent = nullptr); + virtual ~VFileDevice(); virtual void close() override; virtual bool seek(qint64 pos) override; @@ -29,6 +30,7 @@ public: VFileDevice& operator=(VFile*); operator VFile*() { return m_vf; } + VFile* take(); static VFile* wrap(QIODevice*, QIODevice::OpenMode); static VFile* wrap(QFileDevice*, QIODevice::OpenMode);