forked from qt-creator/qt-creator
BinEditor: Check some optional values
and use the non-throwing operator* Change-Id: Idddddf65ddea7fc269c672fced3d57ee55b0ded4 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1262,8 +1262,11 @@ void BinEditorWidget::mousePressEvent(QMouseEvent *e)
|
|||||||
{
|
{
|
||||||
if (e->button() != Qt::LeftButton)
|
if (e->button() != Qt::LeftButton)
|
||||||
return;
|
return;
|
||||||
|
const std::optional<qint64> pos = posAt(e->pos());
|
||||||
|
if (!pos)
|
||||||
|
return;
|
||||||
MoveMode moveMode = e->modifiers() & Qt::ShiftModifier ? KeepAnchor : MoveAnchor;
|
MoveMode moveMode = e->modifiers() & Qt::ShiftModifier ? KeepAnchor : MoveAnchor;
|
||||||
setCursorPosition(posAt(e->pos()).value(), moveMode);
|
setCursorPosition(*pos, moveMode);
|
||||||
setBlinkingCursorEnabled(true);
|
setBlinkingCursorEnabled(true);
|
||||||
if (m_hexCursor == inTextArea(e->pos())) {
|
if (m_hexCursor == inTextArea(e->pos())) {
|
||||||
m_hexCursor = !m_hexCursor;
|
m_hexCursor = !m_hexCursor;
|
||||||
@@ -1275,7 +1278,10 @@ void BinEditorWidget::mouseMoveEvent(QMouseEvent *e)
|
|||||||
{
|
{
|
||||||
if (!(e->buttons() & Qt::LeftButton))
|
if (!(e->buttons() & Qt::LeftButton))
|
||||||
return;
|
return;
|
||||||
setCursorPosition(posAt(e->pos()).value(), KeepAnchor);
|
const std::optional<qint64> pos = posAt(e->pos());
|
||||||
|
if (!pos)
|
||||||
|
return;
|
||||||
|
setCursorPosition(*pos, KeepAnchor);
|
||||||
if (m_hexCursor == inTextArea(e->pos())) {
|
if (m_hexCursor == inTextArea(e->pos())) {
|
||||||
m_hexCursor = !m_hexCursor;
|
m_hexCursor = !m_hexCursor;
|
||||||
updateLines();
|
updateLines();
|
||||||
@@ -1397,7 +1403,7 @@ QString BinEditorWidget::toolTip(const QHelpEvent *helpEvent) const
|
|||||||
std::optional<qint64> pos = posAt(helpEvent->pos(), /*includeEmptyArea*/false);
|
std::optional<qint64> pos = posAt(helpEvent->pos(), /*includeEmptyArea*/false);
|
||||||
if (!pos)
|
if (!pos)
|
||||||
return QString();
|
return QString();
|
||||||
selStart = pos.value();
|
selStart = *pos;
|
||||||
byteCount = 1;
|
byteCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user