Skip to content

Commit

Permalink
Fix almost every warning as of Clang 19
Browse files Browse the repository at this point in the history
* <codecvt> is deprecated, we can use QString's UTF-16 conversion
  instead
* the sem_timedwait implementation had warnings in it, but I just
  removed it entirely because we don't use it anymore anyway
  • Loading branch information
nadiaholmquist committed Dec 25, 2024
1 parent 72c86ad commit 17dbb10
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 523 deletions.
2 changes: 0 additions & 2 deletions src/frontend/qt_sdl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,6 @@ if (WIN32)
endif()

if (APPLE)
target_sources(melonDS PRIVATE sem_timedwait.cpp)

# Copy icon into the bundle
set(RESOURCE_FILES "${CMAKE_SOURCE_DIR}/res/melon.icns")
target_sources(melonDS PUBLIC "${RESOURCE_FILES}")
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/CameraManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ void CameraFrameDumper::present(const QVideoFrame& _frame)
case QVideoFrameFormat::Format_NV12:
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
break;
default:
break;
}

frame.unmap();
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/qt_sdl/DateTimeDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DateTimeDialog : public QDialog
void timerEvent(QTimerEvent* event) override;

private slots:
void done(int r);
void done(int r) override;

void on_chkChangeTime_clicked(bool checked);
void on_chkResetTime_clicked(bool checked);
Expand Down
32 changes: 14 additions & 18 deletions src/frontend/qt_sdl/EmuInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,13 @@ std::optional<DSi_NAND::NANDImage> EmuInstance::loadNAND(const std::array<u8, DS
auto firmcfg = localCfg.GetTable("Firmware");

// we store relevant strings as UTF-8, so we need to convert them to UTF-16
auto converter = wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{};
//auto converter = wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{};

// setting up username
std::u16string username = converter.from_bytes(firmcfg.GetString("Username"));
size_t usernameLength = std::min(username.length(), (size_t) 10);
auto username = firmcfg.GetQString("Username");
size_t usernameLength = std::min(username.length(), (qsizetype) 10);
memset(&settings.Nickname, 0, sizeof(settings.Nickname));
memcpy(&settings.Nickname, username.data(), usernameLength * sizeof(char16_t));
memcpy(&settings.Nickname, username.utf16(), usernameLength * sizeof(char16_t));

// setting language
settings.Language = static_cast<Firmware::Language>(firmcfg.GetInt("Language"));
Expand All @@ -1101,10 +1101,10 @@ std::optional<DSi_NAND::NANDImage> EmuInstance::loadNAND(const std::array<u8, DS
settings.BirthdayDay = firmcfg.GetInt("BirthdayDay");

// setup message
std::u16string message = converter.from_bytes(firmcfg.GetString("Message"));
size_t messageLength = std::min(message.length(), (size_t) 26);
auto message = firmcfg.GetQString("Message");
size_t messageLength = std::min(message.length(), (qsizetype) 26);
memset(&settings.Message, 0, sizeof(settings.Message));
memcpy(&settings.Message, message.data(), messageLength * sizeof(char16_t));
memcpy(&settings.Message, message.utf16(), messageLength * sizeof(char16_t));

// TODO: make other items configurable?
}
Expand Down Expand Up @@ -1670,14 +1670,12 @@ void EmuInstance::customizeFirmware(Firmware& firmware, bool overridesettings) n
auto firmcfg = localCfg.GetTable("Firmware");

// setting up username
std::string orig_username = firmcfg.GetString("Username");
if (!orig_username.empty())
auto username = firmcfg.GetQString("Username");
if (!username.isEmpty())
{ // If the frontend defines a username, take it. If not, leave the existing one.
std::u16string username = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
orig_username);
size_t usernameLength = std::min(username.length(), (size_t) 10);
size_t usernameLength = std::min(username.length(), (qsizetype) 10);
currentData.NameLength = usernameLength;
memcpy(currentData.Nickname, username.data(), usernameLength * sizeof(char16_t));
memcpy(currentData.Nickname, username.utf16(), usernameLength * sizeof(char16_t));
}

auto language = static_cast<Firmware::Language>(firmcfg.GetInt("Language"));
Expand Down Expand Up @@ -1707,12 +1705,10 @@ void EmuInstance::customizeFirmware(Firmware& firmware, bool overridesettings) n
}

// setup message
std::string orig_message = firmcfg.GetString("Message");
if (!orig_message.empty())
auto message = firmcfg.GetQString("Message");
if (!message.isEmpty())
{
std::u16string message = std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t>{}.from_bytes(
orig_message);
size_t messageLength = std::min(message.length(), (size_t) 26);
size_t messageLength = std::min(message.length(), (qsizetype) 26);
currentData.MessageLength = messageLength;
memcpy(currentData.Message, message.data(), messageLength * sizeof(char16_t));
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/qt_sdl/LANDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ void LANDialog::doUpdatePlayerList()
case LAN::Player_Disconnected:
status = "Connection lost";
break;
case LAN::Player_None:
break;
}
model->item(i, 2)->setText(status);

Expand Down
6 changes: 3 additions & 3 deletions src/frontend/qt_sdl/LANDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Q_OBJECT
}

private slots:
void done(int r);
void done(int r) override;

private:
Ui::LANStartHostDialog* ui;
Expand Down Expand Up @@ -76,7 +76,7 @@ private slots:
void onGameSelectionChanged(const QItemSelection& cur, const QItemSelection& prev);
void on_tvAvailableGames_doubleClicked(QModelIndex index);
void onDirectConnect();
void done(int r);
void done(int r) override;

void doUpdateDiscoveryList();

Expand Down Expand Up @@ -105,7 +105,7 @@ Q_OBJECT

private slots:
void on_btnLeaveGame_clicked();
void done(int r);
void done(int r) override;

void doUpdatePlayerList();

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/qt_sdl/MPSettingsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MPSettingsDialog : public QDialog
}

private slots:
void done(int r);
void done(int r) override;

//

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/qt_sdl/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ bool ScreenPanelGL::createContext()
if (ourwin->getWindowID() != 0)
{
if (windowinfo.has_value())
if (glContext = parentwin->getOGLContext()->CreateSharedContext(*windowinfo))
if ((glContext = parentwin->getOGLContext()->CreateSharedContext(*windowinfo)))
glContext->DoneCurrent();
}
else
Expand All @@ -885,7 +885,7 @@ bool ScreenPanelGL::createContext()
GL::Context::Version{GL::Context::Profile::Core, 4, 3},
GL::Context::Version{GL::Context::Profile::Core, 3, 2}};
if (windowinfo.has_value())
if (glContext = GL::Context::Create(*windowinfo, versionsToTry))
if ((glContext = GL::Context::Create(*windowinfo, versionsToTry)))
glContext->DoneCurrent();
}

Expand Down
Loading

0 comments on commit 17dbb10

Please sign in to comment.