diff --git a/src/platform/qt/CoreController.cpp b/src/platform/qt/CoreController.cpp index 5bdc997c2..7cc8d7e1f 100644 --- a/src/platform/qt/CoreController.cpp +++ b/src/platform/qt/CoreController.cpp @@ -998,9 +998,9 @@ void CoreController::attachPrinter() { } GB* gb = static_cast(m_threadContext.core->board); clearMultiplayerController(); - GBPrinterCreate(&m_printer.d); + GBPrinterCreate(&m_printer); m_printer.parent = this; - m_printer.d.print = [](GBPrinter* printer, int height, const uint8_t* data) { + m_printer.print = [](GBPrinter* printer, int height, const uint8_t* data) { QGBPrinter* qPrinter = reinterpret_cast(printer); QImage image(GB_VIDEO_HORIZONTAL_PIXELS, height, QImage::Format_Indexed8); QVector colors; @@ -1021,7 +1021,7 @@ void CoreController::attachPrinter() { QMetaObject::invokeMethod(qPrinter->parent, "imagePrinted", Q_ARG(const QImage&, image)); }; Interrupter interrupter(this); - GBSIOSetDriver(&gb->sio, &m_printer.d.d); + GBSIOSetDriver(&gb->sio, &m_printer.d); } void CoreController::detachPrinter() { @@ -1030,7 +1030,7 @@ void CoreController::detachPrinter() { } Interrupter interrupter(this); GB* gb = static_cast(m_threadContext.core->board); - GBPrinterDonePrinting(&m_printer.d); + GBPrinterDonePrinting(&m_printer); GBSIOSetDriver(&gb->sio, nullptr); } @@ -1039,7 +1039,7 @@ void CoreController::endPrint() { return; } Interrupter interrupter(this); - GBPrinterDonePrinting(&m_printer.d); + GBPrinterDonePrinting(&m_printer); } #endif diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index 9e64bb838..74d9a7b05 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -314,8 +314,7 @@ private: VFile* m_vlVf = nullptr; #ifdef M_CORE_GB - struct QGBPrinter { - GBPrinter d; + struct QGBPrinter : public GBPrinter { CoreController* parent; } m_printer; #endif diff --git a/src/platform/qt/DebuggerConsoleController.cpp b/src/platform/qt/DebuggerConsoleController.cpp index 3a9446b15..bacc97104 100644 --- a/src/platform/qt/DebuggerConsoleController.cpp +++ b/src/platform/qt/DebuggerConsoleController.cpp @@ -19,18 +19,18 @@ using namespace QGBA; DebuggerConsoleController::DebuggerConsoleController(QObject* parent) : DebuggerController(&m_cliDebugger.d, parent) { - m_backend.d.printf = printf; - m_backend.d.init = init; - m_backend.d.deinit = deinit; - m_backend.d.readline = readLine; - m_backend.d.lineAppend = lineAppend; - m_backend.d.historyLast = historyLast; - m_backend.d.historyAppend = historyAppend; - m_backend.d.interrupt = interrupt; + m_backend.printf = printf; + m_backend.init = init; + m_backend.deinit = deinit; + m_backend.readline = readLine; + m_backend.lineAppend = lineAppend; + m_backend.historyLast = historyLast; + m_backend.historyAppend = historyAppend; + m_backend.interrupt = interrupt; m_backend.self = this; CLIDebuggerCreate(&m_cliDebugger); - CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); + CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend); } void DebuggerConsoleController::enterLine(const QString& line) { @@ -60,7 +60,7 @@ void DebuggerConsoleController::attachInternal() { CoreController::Interrupter interrupter(m_gameController); QMutexLocker lock(&m_mutex); mCore* core = m_gameController->thread()->core; - CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend.d); + CLIDebuggerAttachBackend(&m_cliDebugger, &m_backend); CLIDebuggerAttachSystem(&m_cliDebugger, core->cliDebuggerSystem(core)); } diff --git a/src/platform/qt/DebuggerConsoleController.h b/src/platform/qt/DebuggerConsoleController.h index fdf183c08..c3d98d35c 100644 --- a/src/platform/qt/DebuggerConsoleController.h +++ b/src/platform/qt/DebuggerConsoleController.h @@ -56,8 +56,7 @@ private: QStringList m_lines; QByteArray m_last; - struct Backend { - CLIDebuggerBackend d; + struct Backend : public CLIDebuggerBackend { DebuggerConsoleController* self; } m_backend; }; diff --git a/src/platform/qt/VideoProxy.cpp b/src/platform/qt/VideoProxy.cpp index 7c6366229..cf674e1e8 100644 --- a/src/platform/qt/VideoProxy.cpp +++ b/src/platform/qt/VideoProxy.cpp @@ -12,39 +12,40 @@ using namespace QGBA; VideoProxy::VideoProxy() { - mVideoLoggerRendererCreate(&m_logger.d, false); - m_logger.d.block = true; - m_logger.d.waitOnFlush = true; + mVideoLoggerRendererCreate(&m_logger, false); + m_logger.p = this; + m_logger.block = true; + m_logger.waitOnFlush = true; - m_logger.d.init = &cbind<&VideoProxy::init>; - m_logger.d.reset = &cbind<&VideoProxy::reset>; - m_logger.d.deinit = &cbind<&VideoProxy::deinit>; - m_logger.d.lock = &cbind<&VideoProxy::lock>; - m_logger.d.unlock = &cbind<&VideoProxy::unlock>; - m_logger.d.wait = &cbind<&VideoProxy::wait>; - m_logger.d.wake = &callback::func<&VideoProxy::wake>; + m_logger.init = &cbind<&VideoProxy::init>; + m_logger.reset = &cbind<&VideoProxy::reset>; + m_logger.deinit = &cbind<&VideoProxy::deinit>; + m_logger.lock = &cbind<&VideoProxy::lock>; + m_logger.unlock = &cbind<&VideoProxy::unlock>; + m_logger.wait = &cbind<&VideoProxy::wait>; + m_logger.wake = &callback::func<&VideoProxy::wake>; - m_logger.d.writeData = &callback::func<&VideoProxy::writeData>; - m_logger.d.readData = &callback::func<&VideoProxy::readData>; - m_logger.d.postEvent = &callback::func<&VideoProxy::postEvent>; + m_logger.writeData = &callback::func<&VideoProxy::writeData>; + m_logger.readData = &callback::func<&VideoProxy::readData>; + m_logger.postEvent = &callback::func<&VideoProxy::postEvent>; connect(this, &VideoProxy::dataAvailable, this, &VideoProxy::processData); } void VideoProxy::attach(CoreController* controller) { CoreController::Interrupter interrupter(controller); - controller->thread()->core->videoLogger = &m_logger.d; + controller->thread()->core->videoLogger = &m_logger; } void VideoProxy::detach(CoreController* controller) { CoreController::Interrupter interrupter(controller); - if (controller->thread()->core->videoLogger == &m_logger.d) { + if (controller->thread()->core->videoLogger == &m_logger) { controller->thread()->core->videoLogger = nullptr; } } void VideoProxy::processData() { - mVideoLoggerRendererRun(&m_logger.d, false); + mVideoLoggerRendererRun(&m_logger, false); m_fromThreadCond.wakeAll(); } @@ -67,7 +68,7 @@ bool VideoProxy::writeData(const void* data, size_t length) { while (!RingFIFOWrite(&m_dirtyQueue, data, length)) { if (QThread::currentThread() == thread()) { // We're on the main thread - mVideoLoggerRendererRun(&m_logger.d, false); + mVideoLoggerRendererRun(&m_logger, false); } else { emit dataAvailable(); m_mutex.lock(); @@ -105,7 +106,7 @@ void VideoProxy::postEvent(enum mVideoLoggerEvent event) { void VideoProxy::handleEvent(int event) { m_mutex.lock(); - m_logger.d.handleEvent(&m_logger.d, static_cast(event)); + m_logger.handleEvent(&m_logger, static_cast(event)); m_mutex.unlock(); } @@ -122,7 +123,7 @@ void VideoProxy::wait() { while (RingFIFOSize(&m_dirtyQueue)) { if (QThread::currentThread() == thread()) { // We're on the main thread - mVideoLoggerRendererRun(&m_logger.d, false); + mVideoLoggerRendererRun(&m_logger, false); } else { emit dataAvailable(); m_toThreadCond.wakeAll(); diff --git a/src/platform/qt/VideoProxy.h b/src/platform/qt/VideoProxy.h index 3ba845617..4e16c1f90 100644 --- a/src/platform/qt/VideoProxy.h +++ b/src/platform/qt/VideoProxy.h @@ -24,7 +24,7 @@ public: void attach(CoreController*); void detach(CoreController*); - void setBlocking(bool block) { m_logger.d.waitOnFlush = block; } + void setBlocking(bool block) { m_logger.waitOnFlush = block; } signals: void dataAvailable(); @@ -51,17 +51,16 @@ private: using type = T (VideoProxy::*)(A...); template static T func(mVideoLogger* logger, A... args) { - VideoProxy* proxy = reinterpret_cast(logger)->p; + VideoProxy* proxy = static_cast(logger)->p; return (proxy->*F)(args...); } }; template static void cbind(mVideoLogger* logger) { callback::func(logger); } - struct Logger { - mVideoLogger d; + struct Logger : public mVideoLogger { VideoProxy* p; - } m_logger = {{}, this}; + } m_logger; RingFIFO m_dirtyQueue; QMutex m_mutex;