Skip to content

Commit 68f44a6

Browse files
committed
Fix all build warnings in our code
Replace deprecated Qt 5 APIs with Qt 6 equivalents: - QVariant::Type enum with QMetaType::Type (Int, Double, QColor, QPointF, QSize) - QVariant::type() with typeId() - Q_OS_OSX with Q_OS_MACOS - QMouseEvent::globalPos() with globalPosition().toPoint() Silence OpenGL deprecation warnings on macOS with GL_SILENCE_DEPRECATION. Remove QT_DISABLE_DEPRECATED_BEFORE=0 from qtpropertybrowser build config. Fix unused variables and parameters, suppress nodiscard warnings. We cannot replace QImage::mirrored() with flipped(), though: for Qt < 6.8 compatibility QImage::flipped() requires Qt 6.8+. Use mirrored() with warning suppression macros to maintain compatibility with older Qt 6 versions.
1 parent b687db3 commit 68f44a6

17 files changed

Lines changed: 54 additions & 44 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ trash
9393
!resources/macOS/MapMap.icns
9494

9595
*.json
96+
97+
# Local development notes
98+
KNOWN-WARNINGS.txt

src/app/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ int main(int argc, char *argv[])
143143
qtTranslator.load(QString("qt_%1").arg(lang),
144144
QApplication::applicationDirPath().append("/translations"));
145145
#else
146-
qtTranslator.load(QString("qtbase_%1").arg(lang),
146+
(void)qtTranslator.load(QString("qtbase_%1").arg(lang),
147147
QLibraryInfo::path(QLibraryInfo::TranslationsPath));
148148
#endif
149149
app.installTranslator(&qtTranslator);
150150

151-
appTranslator.load(QString(":/translations_mapmap_%1").arg(lang));
151+
(void)appTranslator.load(QString(":/translations_mapmap_%1").arg(lang));
152152
app.installTranslator(&appTranslator);
153153
}
154154
else {
@@ -177,7 +177,7 @@ int main(int argc, char *argv[])
177177

178178
// Load stylesheet.
179179
QFile stylesheet(":/stylesheet");
180-
stylesheet.open(QFile::ReadOnly);
180+
(void)stylesheet.open(QFile::ReadOnly);
181181
app.setStyleSheet(QLatin1String(stylesheet.readAll()));
182182

183183
// read positional argument:

src/control/OscInterface.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void OscInterface::messageReceivedCb(const QString& oscAddress, const QVariantLi
9090
QString types = "";
9191
for (int i = 0; i < arguments.count(); ++ i) {
9292
QVariant argument = arguments[i];
93-
QMetaType::Type type = static_cast<QMetaType::Type>(argument.type());
93+
QMetaType::Type type = static_cast<QMetaType::Type>(argument.typeId());
9494

9595
if (type == QMetaType::Int) {
9696
types += "i";
@@ -126,15 +126,15 @@ static void printCommand(QVariantList &command)
126126
{
127127
for (int i = 0; i < command.size(); ++i)
128128
{
129-
if (command.at(i).type() == QVariant::Int)
129+
if (command.at(i).typeId() == QMetaType::Int)
130130
{
131131
qDebug() << command.at(i).toInt() << " ";
132132
}
133-
else if (command.at(i).type() == QVariant::Double)
133+
else if (command.at(i).typeId() == QMetaType::Double)
134134
{
135135
qDebug() << command.at(i).toDouble() << " ";
136136
}
137-
else if (command.at(i).type() == QVariant::String)
137+
else if (command.at(i).typeId() == QMetaType::QString)
138138
{
139139
qDebug() << command.at(i).toString() << " ";
140140
}
@@ -161,11 +161,11 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma
161161
{
162162
return;
163163
}
164-
if (command.at(0).type() != QVariant::String)
164+
if (command.at(0).typeId() != QMetaType::QString)
165165
{
166166
return;
167167
}
168-
if (command.at(1).type() != QVariant::String)
168+
if (command.at(1).typeId() != QMetaType::QString)
169169
{
170170
return;
171171
}
@@ -192,7 +192,7 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma
192192
if (command.size() >= 3)
193193
{
194194
QVector<Source::ptr> sources;
195-
if (command.at(2).type() == QVariant::String)
195+
if (command.at(2).typeId() == QMetaType::QString)
196196
sources = main_window.getMappingManager().getSourcesByNameRegExp(command.at(2).toString());
197197
else
198198
{
@@ -225,7 +225,7 @@ void OscInterface::applyOscCommand(MainWindow &main_window, QVariantList & comma
225225
if (command.size() >= 3)
226226
{
227227
QVector<Layer::ptr> layers;
228-
if (command.at(2).type() == QVariant::String)
228+
if (command.at(2).typeId() == QMetaType::QString)
229229
layers = main_window.getMappingManager().getLayersByNameRegExp(command.at(2).toString());
230230
else
231231
{

src/control/qosc/oscsender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void OscSender::variantListToByteArray(QByteArray& outputResult, const QString&
4141

4242
for (int i = 0; i < arguments.count(); ++ i) {
4343
QVariant argument = arguments[i];
44-
QMetaType::Type type = static_cast<QMetaType::Type>(argument.type());
44+
QMetaType::Type type = static_cast<QMetaType::Type>(argument.typeId());
4545

4646
if (type == QMetaType::Int) {
4747
packet << argument.toInt();

src/core/CameraSurface.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ void CameraSurface::onVideoFrameChanged(const QVideoFrame& frame)
4141
_temporaryImage = img;
4242
#else
4343
// Straighten the image for OpenGL (bottom-left origin convention).
44+
QT_WARNING_PUSH
45+
QT_WARNING_DISABLE_DEPRECATED
4446
_temporaryImage = img.mirrored(true, false).transformed(QTransform().rotate(180));
47+
QT_WARNING_POP
4548
#endif
4649
}
4750

src/core/Source.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ void Image::build()
108108
_images.clear();
109109
for (int i = 0; i < reader.imageCount(); i++) {
110110
QImage raw = reader.read().convertToFormat(QImage::Format_RGBA8888);
111+
QT_WARNING_PUSH
112+
QT_WARNING_DISABLE_DEPRECATED
111113
_images.push_back(raw.mirrored(true, false).transformed(QTransform().rotate(180)));
114+
QT_WARNING_POP
112115
}
113116

114117
rewind();

src/gui/AboutDialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ void AboutDialog::createAboutTab()
9595
QString copyrightText = "<p>" + tr("Copyright &copy; 2013 %1.").arg(MM::COPYRIGHT_OWNERS) + "</p>";
9696
// License short notice
9797
QFile licenseShortFile(":/license-short");
98-
licenseShortFile.open(QIODevice::ReadOnly | QIODevice::Text);
98+
(void)licenseShortFile.open(QIODevice::ReadOnly | QIODevice::Text);
9999
QString licenseNoticeText = Qt::convertFromPlainText(QString::fromUtf8(licenseShortFile.readAll()), Qt::WhiteSpaceNormal);
100100
// About projection mapping
101101
QFile aboutMappingFile(":/projection-mapping");
102-
aboutMappingFile.open(QIODevice::ReadOnly | QIODevice::Text);
102+
(void)aboutMappingFile.open(QIODevice::ReadOnly | QIODevice::Text);
103103
QString aboutMappingText = QString::fromUtf8(aboutMappingFile.readAll());
104104
// Visit our website for more information
105105
QString projectWebsiteText = "<p>" + tr("See the ") + QString("<a href=\"%1\">").arg(MM::WEBSITE_URL) +
@@ -126,7 +126,7 @@ void AboutDialog::createChangelogTab()
126126
changelogTextBrowser->setOpenExternalLinks(true);
127127

128128
QFile changelogFile(":/changelog_md");
129-
changelogFile.open(QIODevice::ReadOnly | QIODevice::Text);
129+
(void)changelogFile.open(QIODevice::ReadOnly | QIODevice::Text);
130130
changelogTextBrowser->setMarkdown(QString::fromUtf8(changelogFile.readAll()));
131131
_tabWidget->addTab(changelogTextBrowser, tr("Changelog"));
132132
}
@@ -152,7 +152,7 @@ void AboutDialog::createContributorsTab()
152152
contributorsTextBrowser->setOpenExternalLinks(true);
153153

154154
QFile contributorsFile(":/contributors_md");
155-
contributorsFile.open(QIODevice::ReadOnly | QIODevice::Text);
155+
(void)contributorsFile.open(QIODevice::ReadOnly | QIODevice::Text);
156156
contributorsTextBrowser->setMarkdown(QString::fromUtf8(contributorsFile.readAll()));
157157
_tabWidget->addTab(contributorsTextBrowser, tr("Contributors"));
158158
}
@@ -163,7 +163,7 @@ void AboutDialog::createLicenseTab()
163163
licenseTextBrowser->setOpenExternalLinks(true);
164164

165165
QFile licenseFile(":/license");
166-
licenseFile.open(QIODevice::ReadOnly | QIODevice::Text);
166+
(void)licenseFile.open(QIODevice::ReadOnly | QIODevice::Text);
167167
licenseTextBrowser->setText(QString::fromUtf8(licenseFile.readAll()));
168168

169169
_tabWidget->addTab(licenseTextBrowser, tr("License"));
@@ -176,7 +176,7 @@ void AboutDialog::createOscTab()
176176
oscBrowser->setOpenExternalLinks(true);
177177

178178
QFile oscFile(":/osc-documentation_md");
179-
oscFile.open(QIODevice::ReadOnly | QIODevice::Text);
179+
(void)oscFile.open(QIODevice::ReadOnly | QIODevice::Text);
180180
oscBrowser->setMarkdown(QString::fromUtf8(oscFile.readAll()));
181181
_tabWidget->addTab(oscBrowser, tr("OSC Commands"));
182182
}

src/gui/ConsoleWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void ConsoleWindow::writeLogFile(const QString &message)
8686
{
8787
QString logFilePath = QDir(QDir::tempPath()).filePath("mapmap.log");
8888
QFile logFile(logFilePath);
89-
logFile.open(QIODevice::Append);
89+
(void)logFile.open(QIODevice::Append);
9090
QTextStream stream(&logFile);
9191
stream << message << Qt::endl;
9292
}

src/gui/LayerGui.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ LayerGui::LayerGui(Layer::ptr layer)
4141
_sourceEnumManager = new QtEnumPropertyManager(this);
4242

4343
// Mapping UID.
44-
_idItem = _variantManager->addProperty(QVariant::Int, QObject::tr("ID"));
44+
_idItem = _variantManager->addProperty(QMetaType::Int, QObject::tr("ID"));
4545
_idItem->setEnabled(false);
4646
_idItem->setValue(_layer->getId());
4747
_propertyBrowser->addProperty(_idItem);
4848

4949
// Mapping basic properties.
50-
_opacityItem = _variantManager->addProperty(QVariant::Double, QObject::tr("Opacity (%)"));
50+
_opacityItem = _variantManager->addProperty(QMetaType::Double, QObject::tr("Opacity (%)"));
5151
_opacityItem->setAttribute("minimum", 0.0);
5252
_opacityItem->setAttribute("maximum", 100.0);
5353
_opacityItem->setAttribute("decimals", 1);
@@ -147,7 +147,7 @@ void LayerGui::_buildShapeProperty(QtProperty* shapeItem, MShape* shape)
147147
for (int i=0; i<shape->nVertices(); i++)
148148
{
149149
// Add point.
150-
QtVariantProperty* pointItem = _variantManager->addProperty(QVariant::PointF,
150+
QtVariantProperty* pointItem = _variantManager->addProperty(QMetaType::QPointF,
151151
QObject::tr("Point %1").arg(i));
152152

153153
const QPointF& p = shape->getVertex(i);
@@ -192,7 +192,7 @@ MeshColorLayerGui::MeshColorLayerGui(Layer::ptr layer)
192192

193193
// Add mesh sub property.
194194
QSharedPointer<Mesh> mesh = qSharedPointerCast<Mesh>(_layer->getShape());
195-
_meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Mesh Subdivisions"));
195+
_meshItem = _variantManager->addProperty(QMetaType::QSize, QObject::tr("Mesh Subdivisions"));
196196
_meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows()));
197197
_meshItem->setAttribute("minimum", QSize(2,2));
198198
_propertyBrowser->insertProperty(_meshItem, _sourceItem); // insert at the beginning
@@ -228,7 +228,7 @@ EllipseColorLayerGui::EllipseColorLayerGui(Layer::ptr layer) : ColorLayerGui(lay
228228
// : ColorLayerGui(layer) {
229229
// // Add mesh sub property.
230230
// Mesh* mesh = (Mesh*)layer->getShape().get();
231-
// _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Mesh Subdivisions"));
231+
// _meshItem = _variantManager->addProperty(QMetaType::QSize, QObject::tr("Mesh Subdivisions"));
232232
// _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows()));
233233
// _topItem->insertSubProperty(_meshItem, 0); // insert at the beginning
234234
//}
@@ -421,7 +421,7 @@ MeshTextureLayerGui::MeshTextureLayerGui(QSharedPointer<TextureLayer> mapping)
421421

422422
// Add mesh sub property.
423423
QSharedPointer<Mesh> mesh = qSharedPointerCast<Mesh>(_layer->getShape());
424-
_meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Subdivisions"));
424+
_meshItem = _variantManager->addProperty(QMetaType::QSize, QObject::tr("Subdivisions"));
425425

426426
// Rename subdivision subproperties.
427427
QList<QtProperty *> subList = _meshItem->subProperties();

src/gui/LayerListModel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,23 @@ bool LayerListModel::setData(const QModelIndex &index, const QVariant &value, in
170170
if (!index.isValid())
171171
return false;
172172

173-
if (role == Qt::CheckStateRole && value.type() == QVariant::Bool) {
173+
if (role == Qt::CheckStateRole && value.typeId() == QMetaType::Bool) {
174174
if (layerList[index.row()].isVisible != value.toBool()) {
175175
layerList[index.row()].isVisible = value.toBool();
176176
emit dataChanged(index, index);
177177
return true;
178178
}
179179
}
180180

181-
if (role == Qt::CheckStateRole + 1 && value.type() == QVariant::Bool) {
181+
if (role == Qt::CheckStateRole + 1 && value.typeId() == QMetaType::Bool) {
182182
if (layerList[index.row()].isSolo != value.toBool()) {
183183
layerList[index.row()].isSolo = value.toBool();
184184
emit dataChanged(index, index);
185185
return true;
186186
}
187187
}
188188

189-
if (role == Qt::CheckStateRole + 2 && value.type() == QVariant::Bool) {
189+
if (role == Qt::CheckStateRole + 2 && value.typeId() == QMetaType::Bool) {
190190
if (layerList[index.row()].isLocked != value.toBool()) {
191191
layerList[index.row()].isLocked = value.toBool();
192192
emit dataChanged(index, index);

0 commit comments

Comments
 (0)