QmlDesigner: Use the noexcept interface for optional and unexpected

Optional and unexpected have a interface designed after pointer usage.
That cannot throw exceptions. They added continuation too. That is
making it harder to make mistakes.

Change-Id: Ie9d41a2e69c7467a7e4ac4999825aede1326e529
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2024-05-24 13:42:38 +02:00
parent b8322aece2
commit fd8cef3c6e
4 changed files with 7 additions and 8 deletions

View File

@@ -422,7 +422,7 @@ QVariant KeyframeItem::itemChange(QGraphicsItem::GraphicsItemChange change, cons
rseg.moveLeftTo(position); rseg.moveLeftTo(position);
if (legalLeft() && legalRight()) { if (legalLeft() && legalRight()) {
if (qApp->keyboardModifiers().testFlag(Qt::ShiftModifier) && m_validPos.has_value()) { if (qApp->keyboardModifiers().testFlag(Qt::ShiftModifier) && m_validPos) {
if (m_firstPos) { if (m_firstPos) {
auto firstToNow = QLineF(*m_firstPos, position); auto firstToNow = QLineF(*m_firstPos, position);
if (std::abs(firstToNow.dx()) > std::abs(firstToNow.dy())) if (std::abs(firstToNow.dx()) > std::abs(firstToNow.dy()))

View File

@@ -284,10 +284,9 @@ void DesignDocument::moveNodesToPosition(const QList<ModelNode> &nodes, const st
parentProperty.reparentHere(pastedNode); parentProperty.reparentHere(pastedNode);
QmlVisualNode visualNode(pastedNode); QmlVisualNode visualNode(pastedNode);
if (!firstVisualNode.has_value() && visualNode.isValid()){ if (!firstVisualNode && visualNode) {
firstVisualNode = visualNode; firstVisualNode = visualNode;
translationVect = (position.has_value() && firstVisualNode.has_value()) translationVect = (position && firstVisualNode) ? *position - firstVisualNode->position()
? position.value() - firstVisualNode->position()
: QVector3D(); : QVector3D();
} }
visualNode.translate(translationVect); visualNode.translate(translationVect);

View File

@@ -18,7 +18,7 @@ bool couldBeProjectModule(const Utils::FilePath &path, const QString &projectNam
return false; return false;
const QString expectedLine = QLatin1String("module %1").arg(projectName); const QString expectedLine = QLatin1String("module %1").arg(projectName);
QByteArray fileContents = qmldirContents.value(); QByteArray fileContents = *qmldirContents;
QTextStream stream(fileContents); QTextStream stream(fileContents);
while (!stream.atEnd()) { while (!stream.atEnd()) {
QString lineData = stream.readLine().trimmed(); QString lineData = stream.readLine().trimmed();

View File

@@ -184,8 +184,8 @@ void QmlVisualNode::scatter(const ModelNode &targetNode, const std::optional<int
if (!scatter) if (!scatter)
return; return;
if (offset.has_value()) { // offset if (offset) { // offset
double offsetValue = offset.value(); double offsetValue = *offset;
this->translate(QVector3D(offsetValue, offsetValue, offsetValue)); this->translate(QVector3D(offsetValue, offsetValue, offsetValue));
} else { // scatter in range } else { // scatter in range
const double scatterRange = 20.; const double scatterRange = 20.;