fix: warnings when compiling with Qt 6.10 (#6422)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
- Dev: Correct handling of eventsubs without any account. (#6503)
|
||||
- Dev: Removed dependency to Qt5 Compatibility module by updating libcommuni. (#6500)
|
||||
- Dev: Merged emote element flags from different providers into two. (#6511)
|
||||
- Dev: Fixed warnings on Qt 6.10. (#6422)
|
||||
- Dev: Removed unused method in `Emojis`. (#6517)
|
||||
- Dev: Refactored `Emotes` into `EmoteController`. (#6516)
|
||||
- Dev: Added Qt keyword and warning flags project wide. (#6520)
|
||||
|
||||
@@ -137,6 +137,10 @@ find_package(Qt${MAJOR_QT_VERSION} REQUIRED
|
||||
Svg
|
||||
Concurrent
|
||||
)
|
||||
if(CHATTERINO_ALLOW_PRIVATE_QT_API)
|
||||
# Only exists since 6.10 and prints a warning regarding private headers
|
||||
find_package(Qt${MAJOR_QT_VERSION} COMPONENTS GuiPrivate)
|
||||
endif()
|
||||
|
||||
message(STATUS "Qt version: ${Qt${MAJOR_QT_VERSION}_VERSION}")
|
||||
|
||||
|
||||
@@ -17,10 +17,12 @@ public:
|
||||
explicit EmptyApplication(const QString &settingsData)
|
||||
{
|
||||
QFile settingsFile(this->settingsDir.filePath("settings.json"));
|
||||
settingsFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
settingsFile.write(settingsData.toUtf8());
|
||||
settingsFile.flush();
|
||||
settingsFile.close();
|
||||
if (settingsFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
settingsFile.write(settingsData.toUtf8());
|
||||
settingsFile.flush();
|
||||
settingsFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
~EmptyApplication() override = default;
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ void createRunningFile(const QString &path)
|
||||
{
|
||||
QFile runningFile(path);
|
||||
|
||||
runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
std::ignore = runningFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||
runningFile.flush();
|
||||
runningFile.close();
|
||||
}
|
||||
|
||||
@@ -65,14 +65,21 @@ QString insecurePath()
|
||||
QJsonDocument loadInsecure()
|
||||
{
|
||||
QFile file(insecurePath());
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return QJsonDocument::fromJson(file.readAll());
|
||||
}
|
||||
|
||||
void storeInsecure(const QJsonDocument &doc)
|
||||
{
|
||||
QSaveFile file(insecurePath());
|
||||
file.open(QIODevice::WriteOnly);
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
return;
|
||||
}
|
||||
file.write(doc.toJson());
|
||||
file.commit();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#define QT_NO_CAST_FROM_ASCII // avoids unexpected implicit casts
|
||||
#include "common/LinkParser.hpp"
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "util/QCompareTransparent.hpp"
|
||||
|
||||
#include <QFile>
|
||||
@@ -20,7 +21,12 @@ TldSet &tlds()
|
||||
{
|
||||
static TldSet tlds = [] {
|
||||
QFile file(QStringLiteral(":/tlds.txt"));
|
||||
file.open(QFile::ReadOnly);
|
||||
bool ok = file.open(QFile::ReadOnly);
|
||||
if (!ok)
|
||||
{
|
||||
assert(false && "Resources not available");
|
||||
qCWarning(chatterinoApp) << "Resources not available";
|
||||
}
|
||||
QTextStream stream(&file);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
|
||||
@@ -9,7 +9,10 @@ namespace chatterino {
|
||||
Modes::Modes()
|
||||
{
|
||||
QFile file(combinePath(QCoreApplication::applicationDirPath(), "modes"));
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (!file.atEnd())
|
||||
{
|
||||
|
||||
@@ -14,7 +14,10 @@ namespace {
|
||||
QJsonArray loadWindowArray(const QString &settingsPath)
|
||||
{
|
||||
QFile file(settingsPath);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
QByteArray data = file.readAll();
|
||||
QJsonDocument document = QJsonDocument::fromJson(data);
|
||||
QJsonArray windows_arr = document.object().value("windows").toArray();
|
||||
|
||||
@@ -92,7 +92,12 @@ bool PluginController::tryLoadFromDir(const QDir &pluginDir)
|
||||
return false;
|
||||
}
|
||||
QFile infoFile(infojson.absoluteFilePath());
|
||||
infoFile.open(QIODevice::ReadOnly);
|
||||
if (!infoFile.open(QIODevice::ReadOnly))
|
||||
{
|
||||
qCWarning(chatterinoLua)
|
||||
<< "Could not open info.json" << infoFile.errorString();
|
||||
return false;
|
||||
}
|
||||
auto everything = infoFile.readAll();
|
||||
auto doc = QJsonDocument::fromJson(everything);
|
||||
if (!doc.isObject())
|
||||
|
||||
@@ -172,7 +172,12 @@ void Emojis::loadEmojis()
|
||||
{
|
||||
// Current version: https://github.com/iamcal/emoji-data/blob/v15.1.1/emoji.json (Emoji version 15.1 (2023))
|
||||
QFile file(":/emoji.json");
|
||||
file.open(QFile::ReadOnly);
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
{
|
||||
assert(false && "Resources not available");
|
||||
qCWarning(chatterinoEmoji) << "Resources not available";
|
||||
return;
|
||||
}
|
||||
QTextStream s1(&file);
|
||||
QString data = s1.readAll();
|
||||
rapidjson::Document root;
|
||||
|
||||
@@ -140,7 +140,12 @@ void ImageUploader::logToFile(const QString &originalFilePath,
|
||||
// local path to an image (can be empty)
|
||||
// timestamp
|
||||
QSaveFile logSaveFile(logFileName);
|
||||
logSaveFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
if (!logSaveFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
qCDebug(chatterinoImageuploader)
|
||||
<< "Failed to open log file" << logSaveFile.errorString();
|
||||
return;
|
||||
}
|
||||
QJsonArray entries = QJsonDocument::fromJson(logs).array();
|
||||
entries.push_back(newLogEntry);
|
||||
logSaveFile.write(QJsonDocument(entries).toJson());
|
||||
|
||||
@@ -178,7 +178,13 @@ void Updates::installUpdates()
|
||||
combinePath(this->paths.miscDirectory, "update.zip");
|
||||
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
|
||||
if (!file.open(QIODevice::Truncate | QIODevice::WriteOnly))
|
||||
{
|
||||
qCWarning(chatterinoUpdate)
|
||||
<< "Failed to save update.zip" << file.errorString();
|
||||
this->setStatus_(WriteFileFailed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (file.write(object) == -1)
|
||||
{
|
||||
@@ -238,7 +244,9 @@ void Updates::installUpdates()
|
||||
combinePath(this->paths.miscDirectory, "Update.exe");
|
||||
|
||||
QFile file(filePath);
|
||||
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
|
||||
// write() will fail if we couldn't open
|
||||
std::ignore =
|
||||
file.open(QIODevice::Truncate | QIODevice::WriteOnly);
|
||||
|
||||
if (file.write(object) == -1)
|
||||
{
|
||||
|
||||
@@ -128,7 +128,12 @@ void LoggingChannel::openLogFile()
|
||||
qCDebug(chatterinoHelper) << "Logging to" << fileName;
|
||||
this->fileHandle.setFileName(fileName);
|
||||
|
||||
this->fileHandle.open(QIODevice::Append);
|
||||
if (!this->fileHandle.open(QIODevice::Append))
|
||||
{
|
||||
qCDebug(chatterinoHelper)
|
||||
<< "Failed to open file" << this->fileHandle.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
appendLine(this->fileHandle, generateOpeningString(now));
|
||||
}
|
||||
@@ -159,7 +164,13 @@ void LoggingChannel::openStreamLogFile(const QString &streamID)
|
||||
qCDebug(chatterinoHelper) << "Logging stream to" << fileName;
|
||||
this->currentStreamFileHandle.setFileName(fileName);
|
||||
|
||||
this->currentStreamFileHandle.open(QIODevice::Append);
|
||||
if (!this->currentStreamFileHandle.open(QIODevice::Append))
|
||||
{
|
||||
qCDebug(chatterinoHelper)
|
||||
<< "Failed to open file"
|
||||
<< this->currentStreamFileHandle.errorString();
|
||||
return;
|
||||
}
|
||||
appendLine(this->currentStreamFileHandle, generateOpeningString(now));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "common/Args.hpp"
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/commands/CommandController.hpp"
|
||||
#include "controllers/hotkeys/HotkeyController.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
@@ -47,7 +48,11 @@ SettingsDialog::SettingsDialog(QWidget *parent)
|
||||
this->resize(915, 600);
|
||||
this->themeChangedEvent();
|
||||
QFile styleFile(":/qss/settings.qss");
|
||||
styleFile.open(QFile::ReadOnly);
|
||||
if (!styleFile.open(QFile::ReadOnly))
|
||||
{
|
||||
assert(false && "Resources not loaded");
|
||||
qCWarning(chatterinoWidget) << "Resources not loaded";
|
||||
}
|
||||
QString stylesheet = QString::fromUtf8(styleFile.readAll());
|
||||
this->setStyleSheet(stylesheet);
|
||||
|
||||
|
||||
@@ -158,7 +158,11 @@ AboutPage::AboutPage()
|
||||
auto l = contributors.emplace<FlowLayout>();
|
||||
|
||||
QFile contributorsFile(":/contributors.txt");
|
||||
contributorsFile.open(QFile::ReadOnly);
|
||||
if (!contributorsFile.open(QFile::ReadOnly))
|
||||
{
|
||||
assert(false && "Resources not loaded");
|
||||
qCWarning(chatterinoWidget) << "Resources not loaded";
|
||||
}
|
||||
|
||||
QTextStream stream(&contributorsFile);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
@@ -265,7 +269,12 @@ void AboutPage::addLicense(QFormLayout *form, const QString &name,
|
||||
auto *edit = new QTextEdit;
|
||||
|
||||
QFile file(licenseLink);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
assert(false && "License not found");
|
||||
qCWarning(chatterinoWidget)
|
||||
<< "License not found" << licenseLink;
|
||||
}
|
||||
edit->setText(file.readAll());
|
||||
edit->setReadOnly(true);
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <QColor>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QStandardItemModel>
|
||||
#include <QTableView>
|
||||
@@ -105,9 +106,15 @@ CommandPage::CommandPage()
|
||||
auto *button = new QPushButton("Import commands from Chatterino 1");
|
||||
this->view->addCustomButton(button);
|
||||
|
||||
QObject::connect(button, &QPushButton::clicked, this, [] {
|
||||
QObject::connect(button, &QPushButton::clicked, this, [this] {
|
||||
QFile c1settings(c1settingsPath());
|
||||
c1settings.open(QIODevice::ReadOnly);
|
||||
if (!c1settings.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QMessageBox::warning(
|
||||
this, "Chatterino 1 Importer",
|
||||
"Failed to read settings: " + c1settings.errorString());
|
||||
return;
|
||||
}
|
||||
for (const auto &line :
|
||||
QString(c1settings.readAll())
|
||||
.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts))
|
||||
|
||||
@@ -479,7 +479,7 @@ TEST_F(PluginTest, ioNoPerms)
|
||||
configure();
|
||||
auto file = rawpl->dataDirectory().filePath("testfile");
|
||||
QFile f(file);
|
||||
f.open(QFile::WriteOnly);
|
||||
EXPECT_TRUE(f.open(QFile::WriteOnly));
|
||||
f.write(TEST_FILE_DATA);
|
||||
f.close();
|
||||
|
||||
@@ -531,7 +531,7 @@ TEST_F(PluginTest, requireNoData)
|
||||
|
||||
auto file = rawpl->dataDirectory().filePath("thisiscode.lua");
|
||||
QFile f(file);
|
||||
f.open(QFile::WriteOnly);
|
||||
EXPECT_TRUE(f.open(QFile::WriteOnly));
|
||||
f.write(R"lua(print("Data was executed"))lua");
|
||||
f.close();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user