From 47de0132838f1736e6f27b148ce5aa85514bfcb0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 8 Dec 2020 19:37:13 -0800 Subject: [PATCH] Qt: Add API wrapper for VFileMemChunk --- src/platform/qt/CoreController.cpp | 4 ++-- src/platform/qt/FrameView.cpp | 2 +- src/platform/qt/VFileDevice.cpp | 5 +++++ src/platform/qt/VFileDevice.h | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 014493a74..6f7783491 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -499,7 +499,7 @@ void CoreController::loadState(int slot) { mCoreThreadRunFunction(&m_threadContext, [](mCoreThread* context) { CoreController* controller = static_cast(context->userData); if (!controller->m_backupLoadState.isOpen()) { - controller->m_backupLoadState = VFileMemChunk(nullptr, 0); + controller->m_backupLoadState = VFileDevice::openMemory(); } mCoreSaveStateNamed(context->core, controller->m_backupLoadState, controller->m_saveStateFlags); if (mCoreLoadState(context->core, controller->m_stateSlot, controller->m_loadStateFlags)) { @@ -518,7 +518,7 @@ void CoreController::loadState(const QString& path) { return; } if (!controller->m_backupLoadState.isOpen()) { - controller->m_backupLoadState = VFileMemChunk(nullptr, 0); + controller->m_backupLoadState = VFileDevice::openMemory(); } mCoreSaveStateNamed(context->core, controller->m_backupLoadState, controller->m_saveStateFlags); if (mCoreLoadStateNamed(context->core, vf, controller->m_loadStateFlags)) { diff --git a/src/platform/qt/FrameView.cpp b/src/platform/qt/FrameView.cpp index 5c1efa162..e60e92956 100644 --- a/src/platform/qt/FrameView.cpp +++ b/src/platform/qt/FrameView.cpp @@ -518,7 +518,7 @@ bool FrameView::eventFilter(QObject*, QEvent* event) { void FrameView::refreshVl() { QMutexLocker locker(&m_mutex); m_currentFrame = m_nextFrame; - m_nextFrame = VFileMemChunk(nullptr, 0); + m_nextFrame = VFileDevice::openMemory(); if (m_currentFrame) { m_controller->endVideoLog(false); QMetaObject::invokeMethod(this, "newVl"); diff --git a/src/platform/qt/VFileDevice.cpp b/src/platform/qt/VFileDevice.cpp index 5b4eee49b..052a89e2b 100644 --- a/src/platform/qt/VFileDevice.cpp +++ b/src/platform/qt/VFileDevice.cpp @@ -78,9 +78,14 @@ VFile* VFileDevice::open(const QString& path, int mode) { return VFileOpen(path.toUtf8().constData(), mode); } +VFile* VFileDevice::openMemory() { + return VFileMemChunk(nullptr, 0); +} + VDir* VFileDevice::openDir(const QString& path) { return VDirOpen(path.toUtf8().constData()); } + VDir* VFileDevice::openArchive(const QString& path) { return VDirOpenArchive(path.toUtf8().constData()); } diff --git a/src/platform/qt/VFileDevice.h b/src/platform/qt/VFileDevice.h index 4edc29c47..c43ccef21 100644 --- a/src/platform/qt/VFileDevice.h +++ b/src/platform/qt/VFileDevice.h @@ -29,6 +29,7 @@ public: operator VFile*() { return m_vf; } static VFile* open(const QString& path, int mode); + static VFile* openMemory(); static VDir* openDir(const QString& path); static VDir* openArchive(const QString& path);