-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to Qt6 #619
base: master
Are you sure you want to change the base?
Migrate to Qt6 #619
Conversation
foreach(QT_DEPENDENCY IN LISTS QT_DEPENDENCIES) | ||
target_link_libraries(openbr "Qt6::${QT_DEPENDENCY}") | ||
endforeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_link_libraries wants the Qt components as Qt6::Core
where find_package just wants Core
openbr/openbr.cpp
Outdated
@@ -33,7 +33,7 @@ static int partialCopy(const QString &string, char *buffer, int buffer_length) | |||
{ | |||
const QByteArray byteArray = string.toLocal8Bit(); | |||
|
|||
int copyLength = std::min(buffer_length-1, byteArray.size()); | |||
int copyLength = std::min(buffer_length-1, (int)byteArray.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qsizetype
needs to cast to an int
here for std::min
openbr/openbr_plugin.h
Outdated
@@ -348,7 +348,7 @@ struct TemplateList : public QList<Template> | |||
sum+=partitionSizes[i]; | |||
} | |||
|
|||
if (sum != first().size()) qFatal("Partition sizes %i do not span template matrices %i properly", sum, first().size()); | |||
if (sum != first().size()) qFatal("Partition sizes %i do not span template matrices %lli properly", sum, first().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deal with the warning: format specifies type 'int' but the argument has type 'qsizetype' (aka 'long long') [-Wformat]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qsizetype is signed, so maybe lld
should be used everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think %lld
and %lli
are the same here but lld
is used everywhere else so I'll switch it for consistency
QStringList keys = this->localKeys(); | ||
keys.sort(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qSort has been removed and recommended to use std::sort which is implemented in QStringList::sort()
openbr/openbr_plugin.cpp
Outdated
@@ -1239,46 +1240,46 @@ QStringList br::Context::objects(const char *abstractions, const char *implement | |||
QRegExp abstractionsRegExp(abstractions); | |||
QRegExp implementationsRegExp(implementations); | |||
|
|||
if (abstractionsRegExp.exactMatch("Abbreviation")) | |||
if (abstractionsRegExp.exactMatch("Abbreviation")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suppresses warning: add explicit braces to avoid dangling else [-Wdangling-else]
if (Globals->parallelism) futures.addFuture(QtConcurrent::run(this, &Distance::compareBlock, targets, queries, output, targetOffset, queryOffset)); | ||
if (Globals->parallelism) futures.addFuture(QtConcurrent::run(&Distance::compareBlock, this, targets, queries, output, targetOffset, queryOffset)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to QConcurrent::run described here https://doc.qt.io/qt-6/concurrent-changes-qt6.html
openbr/core/cluster.cpp
Outdated
QList<int> allClusterIDs; | ||
foreach(auto id, nextClusterIDs) { | ||
if (!allClusterIDs.contains(id)) | ||
allClusterIDs.append(id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fromList
is no longer supported. Figured this was simply for removing duplicates so I just implemented that instead of relying on the QSet conversion to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend using QSet range constructor instead
QSet<int> set(list.begin(), list.end());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if there was any value to using QSet
over manually removing the duplicates. QSet
does feel cleaner but it didn't feel right to go from QList --> QSet --> QList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, QSet feels better
openbr/core/cluster.cpp
Outdated
foreach(int clustID, truthVals.toSet()) { | ||
int cnt = truthVals.count(clustID); | ||
if (cnt > max) { | ||
max = cnt; | ||
|
||
QList<int> tempTruthVal = QList<int>(); | ||
foreach(int clustID, truthVals) { | ||
if (!tempTruthVal.contains(clustID)) { | ||
int cnt = truthVals.count(clustID); | ||
if (cnt > max) { | ||
max = cnt; | ||
} | ||
|
||
tempTruthVal.append(clustID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another example of using QSet to remove duplicates. toSet
no longer supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend using QSet range constructor instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, reverted
@@ -50,7 +50,7 @@ class evalOutput : public MatrixOutput | |||
} else { | |||
QFutureSynchronizer<float> futures; | |||
for (int i=0; i<Globals->crossValidate; i++) | |||
futures.addFuture(QtConcurrent::run(Evaluate, data, targetFiles, queryFiles, csv.arg(QString::number(i)), i)); | |||
futures.addFuture(QtConcurrent::run(qOverload<const cv::Mat &, const FileList &, const FileList &, const File &, int>(Evaluate), data, targetFiles, queryFiles, csv.arg(QString::number(i)), i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that QtConcurrent::run does not support calling overloaded functions directly.
openbr/core/cluster.cpp
Outdated
QList<int> allClusterIDs; | ||
foreach(auto id, nextClusterIDs) { | ||
if (!allClusterIDs.contains(id)) | ||
allClusterIDs.append(id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend using QSet range constructor instead
QSet<int> set(list.begin(), list.end());
openbr/core/cluster.cpp
Outdated
foreach(int clustID, truthVals.toSet()) { | ||
int cnt = truthVals.count(clustID); | ||
if (cnt > max) { | ||
max = cnt; | ||
|
||
QList<int> tempTruthVal = QList<int>(); | ||
foreach(int clustID, truthVals) { | ||
if (!tempTruthVal.contains(clustID)) { | ||
int cnt = truthVals.count(clustID); | ||
if (cnt > max) { | ||
max = cnt; | ||
} | ||
|
||
tempTruthVal.append(clustID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recommend using QSet range constructor instead
openbr/openbr_plugin.h
Outdated
@@ -348,7 +348,7 @@ struct TemplateList : public QList<Template> | |||
sum+=partitionSizes[i]; | |||
} | |||
|
|||
if (sum != first().size()) qFatal("Partition sizes %i do not span template matrices %i properly", sum, first().size()); | |||
if (sum != first().size()) qFatal("Partition sizes %i do not span template matrices %lli properly", sum, first().size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qsizetype is signed, so maybe lld
should be used everywhere
openbr/plugins/format/ebts.cpp
Outdated
@@ -58,7 +58,7 @@ class ebtsFormat : public Format | |||
ok = true; | |||
size = qFromBigEndian<quint32>((const uchar*)byteArray.mid(from,4).constData()); | |||
} else { | |||
int index = byteArray.indexOf(QChar(0x1D), from); | |||
int index = byteArray.indexOf("0x1D", from); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"\x1D" i think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we be able to drop the quotes and just put 0x1D
@@ -254,7 +254,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const File &csv, const QStrin | |||
std::vector<float> impostors; impostors.reserve(comparisons.size()); | |||
QVector<int> firstGenuineReturns(simmat.rows, 0); | |||
|
|||
size_t falsePositives = 0, previousFalsePositives = 0; | |||
size_t falsePositives = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jklontz previousFalsePositives
was unused. Just giving it visibility if it should be used.
if (variant.canConvert(QVariant::List)) return toString(qvariant_cast<QVariantList>(variant)); | ||
else if (variant.canConvert(QVariant::String)) return variant.toString(); | ||
else if (variant.canConvert(QVariant::PointF)) { | ||
if (variant.canConvert(QMetaType(QMetaType::QVariantList))) return toString(qvariant_cast<QVariantList>(variant)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version of canConvert is deprecated
Use canConvert(QMetaType(targetTypeId)) instead.
QRegExp re(fileInfo.fileName()); | ||
re.setPatternSyntax(QRegExp::Wildcard); | ||
|
||
QRegularExpression re = QRegularExpression(QRegularExpression::wildcardToRegularExpression(fileInfo.fileName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sold on this is correct. Need to test it in practice. Trying to follow the guide to port to Qt6 here: https://doc.qt.io/qt-6/qregexp.html#porting-to-qregularexpression
QStringList files; | ||
foreach (const QString &fileName, dir.entryList(QDir::Files)) | ||
if (re.exactMatch(fileName)) | ||
if (re.match(fileName).hasMatch()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QRegExp::exactMatch() served two purposes: it exactly matched a regular expression against a subject string, and it implemented partial matching.
Need to figure out still which version of exactMatch we were looking for. Throughout this PR i've implemented the partial match solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following guide here: https://doc.qt.io/qt-6/qregexp.html#porting-to-qregularexpression
@@ -223,19 +223,17 @@ Neighborhood br::loadkNN(const QString &infile) | |||
file.close(); | |||
int min_idx = INT_MAX; | |||
int max_idx = -1; | |||
int count = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
count was unused
No description provided.