fix compilation warnings

This commit is contained in:
oltolm 2024-01-07 12:16:52 +01:00 committed by Vicki Pfau
parent cf54ddd864
commit 3571b112dc
15 changed files with 38 additions and 36 deletions

View File

@ -14,10 +14,6 @@
#define CXX_GUARD_END
#endif
#ifdef __MINGW32__
#define __USE_MINGW_ANSI_STDIO 1
#endif
CXX_GUARD_START
#include <assert.h>

View File

@ -8,7 +8,7 @@
#include <mgba-util/common.h>
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define THREAD_ENTRY DWORD WINAPI
typedef THREAD_ENTRY ThreadEntry(LPVOID);

View File

@ -218,17 +218,17 @@ ADD_CALLBACK(savedataUpdated)
ADD_CALLBACK(alarm)
#undef ADD_CALLBACK
#define CALLBACK(NAME) _script_ ## NAME
#define SCRIPT(NAME) _script_ ## NAME
static void _mCoreThreadAddCallbacks(struct mCoreThread* threadContext) {
struct mCoreCallbacks callbacks = {
.videoFrameEnded = CALLBACK(frame),
.coreCrashed = CALLBACK(crashed),
.sleep = CALLBACK(sleep),
.shutdown = CALLBACK(stop),
.keysRead = CALLBACK(keysRead),
.savedataUpdated = CALLBACK(savedataUpdated),
.alarm = CALLBACK(alarm),
.videoFrameEnded = SCRIPT(frame),
.coreCrashed = SCRIPT(crashed),
.sleep = SCRIPT(sleep),
.shutdown = SCRIPT(stop),
.keysRead = SCRIPT(keysRead),
.savedataUpdated = SCRIPT(savedataUpdated),
.alarm = SCRIPT(alarm),
.context = threadContext
};
threadContext->core->addCoreCallbacks(threadContext->core, &callbacks);

View File

@ -9,6 +9,7 @@
#ifdef BUILD_SDL
#define SDL_MAIN_HANDLED
#include "platform/sdl/sdl-audio.h"
namespace QGBA {

View File

@ -44,13 +44,11 @@ bool ColorPicker::eventFilter(QObject* obj, QEvent* event) {
return false;
}
QWidget* swatch = static_cast<QWidget*>(obj);
QColorDialog* colorPicker = new QColorDialog;
colorPicker->setAttribute(Qt::WA_DeleteOnClose);
colorPicker->setCurrentColor(m_defaultColor);
colorPicker->open();
connect(colorPicker, &QColorDialog::colorSelected, [this, swatch](const QColor& color) {
connect(colorPicker, &QColorDialog::colorSelected, [this](const QColor& color) {
setColor(color);
emit colorChanged(color);
});

View File

@ -232,9 +232,9 @@ bool ForwarderController::toolInstalled(const QString& tool) {
void ForwarderController::connectReply(QNetworkReply* reply, Download download, void (ForwarderController::*next)(QNetworkReply*)) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
connect(reply, &QNetworkReply::errorOccurred, this, [this, reply]() {
connect(reply, &QNetworkReply::errorOccurred, this, [this]() {
#else
connect(reply, qOverload<>(&QNetworkReply::error), this, [this, reply]() {
connect(reply, qOverload<>(&QNetworkReply::error), this, [this]() {
#endif
emit buildFailed();
});

View File

@ -23,7 +23,7 @@ public:
System system() const override { return System::N3DS; }
QString extension() const override { return QLatin1String("cia"); }
virtual QStringList externalTools() const { return {"bannertool", "3dstool", "ctrtool", "makerom"}; }
virtual QStringList externalTools() const override { return {"bannertool", "3dstool", "ctrtool", "makerom"}; }
void rebuild(const QString& source, const QString& target) override;

View File

@ -18,6 +18,7 @@
#include "KeyEditor.h"
#ifdef BUILD_SDL
#define SDL_MAIN_HANDLED
#include "platform/sdl/sdl-events.h"
#endif

View File

@ -26,6 +26,7 @@
#include <mgba/internal/gba/gba.h>
#ifdef BUILD_SDL
#define SDL_MAIN_HANDLED
#include "platform/sdl/sdl-events.h"
#endif

View File

@ -143,7 +143,7 @@ bool ShortcutController::eventFilter(QObject* obj, QEvent* event) {
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
#ifdef ENABLE_SCRIPTING
if (m_scripting) {
m_scripting->event(obj, event);
m_scripting->scriptingEvent(obj, event);
}
#endif
if (keyEvent->isAutoRepeat()) {
@ -165,7 +165,7 @@ bool ShortcutController::eventFilter(QObject* obj, QEvent* event) {
if (event->type() == GamepadButtonEvent::Down()) {
#ifdef ENABLE_SCRIPTING
if (m_scripting) {
m_scripting->event(obj, event);
m_scripting->scriptingEvent(obj, event);
}
#endif
auto item = m_buttons.find(static_cast<GamepadButtonEvent*>(event)->value());
@ -186,7 +186,7 @@ bool ShortcutController::eventFilter(QObject* obj, QEvent* event) {
if (event->type() == GamepadButtonEvent::Up()) {
#ifdef ENABLE_SCRIPTING
if (m_scripting) {
m_scripting->event(obj, event);
m_scripting->scriptingEvent(obj, event);
}
#endif
auto item = m_buttons.find(static_cast<GamepadButtonEvent*>(event)->value());
@ -224,7 +224,7 @@ bool ShortcutController::eventFilter(QObject* obj, QEvent* event) {
#ifdef ENABLE_SCRIPTING
if (event->type() == GamepadHatEvent::Type()) {
if (m_scripting) {
m_scripting->event(obj, event);
m_scripting->scriptingEvent(obj, event);
}
}
#endif

View File

@ -8,6 +8,8 @@
#include "input/Gamepad.h"
#include "input/InputDriver.h"
#define SDL_MAIN_HANDLED
#include "platform/sdl/sdl-events.h"
#include <memory>

View File

@ -109,8 +109,9 @@ int main(int argc, char* argv[]) {
#endif
QTranslator qtTranslator;
qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath));
application.installTranslator(&qtTranslator);
if (qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
application.installTranslator(&qtTranslator);
}
#ifdef QT_STATIC
QTranslator qtStaticTranslator;
@ -119,8 +120,9 @@ int main(int argc, char* argv[]) {
#endif
QTranslator langTranslator;
langTranslator.load(locale, binaryName, "-", ":/translations/");
application.installTranslator(&langTranslator);
if (langTranslator.load(locale, binaryName, "-", ":/translations/")) {
application.installTranslator(&langTranslator);
}
Window* w = application.newWindow();
w->loadConfig();

View File

@ -170,11 +170,11 @@ void ScriptingController::flushStorage() {
}
bool ScriptingController::eventFilter(QObject* obj, QEvent* ev) {
event(obj, ev);
scriptingEvent(obj, ev);
return false;
}
void ScriptingController::event(QObject* obj, QEvent* event) {
void ScriptingController::scriptingEvent(QObject* obj, QEvent* event) {
if (!m_controller) {
return;
}
@ -188,7 +188,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
return;
case QEvent::KeyPress:
case QEvent::KeyRelease: {
struct mScriptKeyEvent ev{mSCRIPT_EV_TYPE_KEY};
struct mScriptKeyEvent ev{{mSCRIPT_EV_TYPE_KEY}};
auto keyEvent = static_cast<QKeyEvent*>(event);
ev.state = event->type() == QEvent::KeyRelease ? mSCRIPT_INPUT_STATE_UP :
static_cast<QKeyEvent*>(event)->isAutoRepeat() ? mSCRIPT_INPUT_STATE_HELD : mSCRIPT_INPUT_STATE_DOWN;
@ -199,7 +199,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
}
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease: {
struct mScriptMouseButtonEvent ev{mSCRIPT_EV_TYPE_MOUSE_BUTTON};
struct mScriptMouseButtonEvent ev{{mSCRIPT_EV_TYPE_MOUSE_BUTTON}};
auto mouseEvent = static_cast<QMouseEvent*>(event);
ev.mouse = 0;
ev.state = event->type() == QEvent::MouseButtonPress ? mSCRIPT_INPUT_STATE_DOWN : mSCRIPT_INPUT_STATE_UP;
@ -208,7 +208,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
return;
}
case QEvent::MouseMove: {
struct mScriptMouseMoveEvent ev{mSCRIPT_EV_TYPE_MOUSE_MOVE};
struct mScriptMouseMoveEvent ev{{mSCRIPT_EV_TYPE_MOUSE_MOVE}};
auto mouseEvent = static_cast<QMouseEvent*>(event);
QPoint pos = mouseEvent->pos();
pos = static_cast<Display*>(obj)->normalizedPoint(m_controller.get(), pos);
@ -219,7 +219,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
return;
}
case QEvent::Wheel: {
struct mScriptMouseWheelEvent ev{mSCRIPT_EV_TYPE_MOUSE_WHEEL};
struct mScriptMouseWheelEvent ev{{mSCRIPT_EV_TYPE_MOUSE_WHEEL}};
auto wheelEvent = static_cast<QWheelEvent*>(event);
QPoint adelta = wheelEvent->angleDelta();
QPoint pdelta = wheelEvent->pixelDelta();
@ -240,7 +240,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
auto type = event->type();
if (type == GamepadButtonEvent::Down() || type == GamepadButtonEvent::Up()) {
struct mScriptGamepadButtonEvent ev{mSCRIPT_EV_TYPE_GAMEPAD_BUTTON};
struct mScriptGamepadButtonEvent ev{{mSCRIPT_EV_TYPE_GAMEPAD_BUTTON}};
auto gamepadEvent = static_cast<GamepadButtonEvent*>(event);
ev.pad = 0;
ev.state = event->type() == GamepadButtonEvent::Down() ? mSCRIPT_INPUT_STATE_DOWN : mSCRIPT_INPUT_STATE_UP;
@ -248,7 +248,7 @@ void ScriptingController::event(QObject* obj, QEvent* event) {
mScriptContextFireEvent(&m_scriptContext, &ev.d);
}
if (type == GamepadHatEvent::Type()) {
struct mScriptGamepadHatEvent ev{mSCRIPT_EV_TYPE_GAMEPAD_HAT};
struct mScriptGamepadHatEvent ev{{mSCRIPT_EV_TYPE_GAMEPAD_HAT}};
updateGamepad();
auto gamepadEvent = static_cast<GamepadHatEvent*>(event);
ev.pad = 0;

View File

@ -43,7 +43,7 @@ public:
bool loadFile(const QString& path);
bool load(VFileDevice& vf, const QString& name);
void event(QObject* obj, QEvent* ev);
void scriptingEvent(QObject* obj, QEvent* ev);
mScriptContext* context() { return &m_scriptContext; }
ScriptingTextBufferModel* textBufferModel() const { return m_bufferModel; }

View File

@ -47,6 +47,7 @@ static void _loadState(struct mCoreThread* thread) {
int main(int argc, char** argv) {
#ifdef _WIN32
AttachConsole(ATTACH_PARENT_PROCESS);
freopen("CONOUT$", "w", stdout);
#endif
struct mSDLRenderer renderer = {0};