Skip to content

Commit b9a6755

Browse files
committed
fix: 2025/10/29 功能冻结缺陷修复;
1 parent 09ed27e commit b9a6755

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2602
-2352
lines changed

3rdparty/QHexView/document/commands/hex/replacecommand.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ int ReplaceCommand::id() const { return UndoID_HexReplaceInsert; }
5858
bool ReplaceCommand::mergeWith(const QUndoCommand *other) {
5959
auto ucmd = dynamic_cast<const ReplaceCommand *>(other);
6060
if (ucmd) {
61+
if (ucmd->m_nibbleindex == 0 &&
62+
this->m_offset + this->m_length - 1 == ucmd->m_offset) {
63+
auto &last = this->m_data.back();
64+
auto front = ucmd->m_data.front();
65+
66+
last &= 0xF0;
67+
front &= 0xF;
68+
last |= front;
69+
70+
if (ucmd->m_data.size() > 1) {
71+
this->m_data.append(ucmd->m_data.sliced(1));
72+
this->m_olddata.append(ucmd->m_olddata.sliced(1));
73+
this->m_length = this->m_data.size();
74+
setText(constructText(this->m_offset, this->m_length));
75+
}
76+
return true;
77+
}
78+
6179
if (this->m_offset == ucmd->m_offset) {
6280
if (this->m_length <= ucmd->m_length) {
6381
this->m_olddata = ucmd->m_olddata;
@@ -71,7 +89,7 @@ bool ReplaceCommand::mergeWith(const QUndoCommand *other) {
7189
}
7290

7391
if (this->m_offset + this->m_length == ucmd->m_offset) {
74-
this->m_length += ucmd->m_offset;
92+
this->m_length += ucmd->m_length;
7593
this->m_data.append(ucmd->m_data);
7694
this->m_olddata.append(ucmd->m_olddata);
7795
this->m_nibbleindex = ucmd->m_nibbleindex;

3rdparty/QHexView/document/qhexdocument.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,11 @@ bool QHexDocument::Insert(QHexCursor *cursor, qsizetype offset,
698698
auto cmd = MakeInsert(nullptr, cursor, offset, data, nibbleindex);
699699
if (cmd) {
700700
m_undostack->push(cmd);
701+
Q_EMIT documentChanged();
701702
} else {
702703
return false;
703704
}
704705

705-
Q_EMIT documentChanged();
706706
return true;
707707
}
708708

@@ -717,8 +717,8 @@ void QHexDocument::Append(QHexCursor *cursor, const QByteArray &data,
717717
auto cmd = MakeAppend(nullptr, cursor, data, nibbleindex);
718718
if (cmd) {
719719
m_undostack->push(cmd);
720+
Q_EMIT documentChanged();
720721
}
721-
Q_EMIT documentChanged();
722722
}
723723

724724
bool QHexDocument::Replace(QHexCursor *cursor, qsizetype offset,
@@ -729,10 +729,10 @@ bool QHexDocument::Replace(QHexCursor *cursor, qsizetype offset,
729729
auto cmd = MakeReplace(nullptr, cursor, offset, data, nibbleindex);
730730
if (cmd) {
731731
m_undostack->push(cmd);
732+
Q_EMIT documentChanged();
732733
} else {
733734
return false;
734735
}
735-
Q_EMIT documentChanged();
736736
return true;
737737
}
738738

@@ -743,8 +743,8 @@ bool QHexDocument::Remove(QHexCursor *cursor, qsizetype offset, qsizetype len,
743743
auto cmd = MakeRemove(nullptr, cursor, offset, len, nibbleindex);
744744
if (cmd) {
745745
m_undostack->push(cmd);
746+
Q_EMIT documentChanged();
746747
}
747-
Q_EMIT documentChanged();
748748
return true;
749749
}
750750

3rdparty/QHexView/document/qhexdocument.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,27 +158,27 @@ public slots:
158158
bool Replace(QHexCursor *cursor, qsizetype offset, uchar b,
159159
int nibbleindex);
160160
bool Replace(QHexCursor *cursor, qsizetype offset, const QByteArray &data,
161-
int nibbleindex = 0);
161+
int nibbleindex = 1);
162162
bool Remove(QHexCursor *cursor, qsizetype offset, qsizetype len,
163-
int nibbleindex = 0);
163+
int nibbleindex = 1);
164164

165165
QUndoCommand *MakeInsert(QUndoCommand *parent, QHexCursor *cursor,
166-
qsizetype offset, uchar b, int nibbleindex = 0);
166+
qsizetype offset, uchar b, int nibbleindex = 1);
167167
QUndoCommand *MakeInsert(QUndoCommand *parent, QHexCursor *cursor,
168168
qsizetype offset, const QByteArray &data,
169-
int nibbleindex = 0);
169+
int nibbleindex = 1);
170170
QUndoCommand *MakeAppend(QUndoCommand *parent, QHexCursor *cursor, uchar b,
171-
int nibbleindex = 0);
171+
int nibbleindex = 1);
172172
QUndoCommand *MakeAppend(QUndoCommand *parent, QHexCursor *cursor,
173-
const QByteArray &data, int nibbleindex = 0);
173+
const QByteArray &data, int nibbleindex = 1);
174174
QUndoCommand *MakeReplace(QUndoCommand *parent, QHexCursor *cursor,
175-
qsizetype offset, uchar b, int nibbleindex = 0);
175+
qsizetype offset, uchar b, int nibbleindex = 1);
176176
QUndoCommand *MakeReplace(QUndoCommand *parent, QHexCursor *cursor,
177177
qsizetype offset, const QByteArray &data,
178-
int nibbleindex = 0);
178+
int nibbleindex = 1);
179179
QUndoCommand *MakeRemove(QUndoCommand *parent, QHexCursor *cursor,
180180
qsizetype offset, qsizetype len,
181-
int nibbleindex = 0);
181+
int nibbleindex = 1);
182182

183183
void pushMakeUndo(QUndoCommand *cmd);
184184

@@ -311,9 +311,9 @@ QHexDocument *QHexDocument::fromDevice(QIODevice *iodevice, bool readonly) {
311311
return nullptr;
312312
}
313313

314+
iodevice->close();
314315
QHexBuffer *hexbuffer = new T();
315316
if (hexbuffer->open(iodevice, readonly)) {
316-
iodevice->close();
317317
return new QHexDocument(hexbuffer);
318318
} else {
319319
iodevice->close();

3rdparty/QHexView/qhexview.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ QHexView::QHexView(QWidget *parent)
187187

188188
connect(m_blinktimer, &QTimer::timeout, this, &QHexView::blinkCursor);
189189

190-
this->setDocument(QSharedPointer<QHexDocument>(
191-
QHexDocument::fromInternalBuffer<QMemoryBuffer>(false)));
190+
resetDocument();
192191
}
193192

194193
QHexView::~QHexView() { m_blinktimer->stop(); }
@@ -243,6 +242,11 @@ void QHexView::setDocument(const QSharedPointer<QHexDocument> &document,
243242
this->viewport()->update();
244243
}
245244

245+
void QHexView::resetDocument() {
246+
this->setDocument(QSharedPointer<QHexDocument>(
247+
QHexDocument::fromInternalBuffer<QMemoryBuffer>(false)));
248+
}
249+
246250
bool QHexView::event(QEvent *e) {
247251
if (m_renderer && (e->type() == QEvent::FontChange)) {
248252
m_renderer->updateMetrics(QFontMetricsF(this->font()));
@@ -362,8 +366,9 @@ qsizetype QHexView::findPrevious(qsizetype begin, const QByteArray &ba) {
362366
}
363367

364368
bool QHexView::RemoveSelection(int nibbleindex) {
365-
if (!m_cursor->hasSelection())
366-
return true;
369+
if (isReadOnly() || isKeepSize()) {
370+
return false;
371+
}
367372

368373
auto total = m_cursor->selectionCount();
369374
auto msg = QStringLiteral("[H-G] {cnt: %1}").arg(total);
@@ -998,20 +1003,17 @@ bool QHexView::processAction(QHexCursor *cur, QKeyEvent *e) {
9981003
if (isKeepSize()) {
9991004
if (cur->insertionMode() == QHexCursor::OverwriteMode) {
10001005
if (e->key() == Qt::Key_Backspace)
1001-
m_document->Replace(m_cursor,
1002-
cur->position().offset() - 1,
1006+
m_document->Replace(m_cursor, pos.offset() - 1,
10031007
uchar(0), 0);
10041008
else
1005-
m_document->Replace(m_cursor, cur->position().offset(),
1006-
uchar(0), 0);
1009+
m_document->Replace(m_cursor, pos.offset(), uchar(0),
1010+
0);
10071011
}
10081012
} else {
10091013
if (e->key() == Qt::Key_Backspace)
1010-
m_document->Remove(m_cursor, cur->position().offset() - 1,
1011-
1, 1);
1014+
m_document->Remove(m_cursor, pos.offset() - 1, 1, 1);
10121015
else
1013-
m_document->Remove(m_cursor, cur->position().offset(), 1,
1014-
0);
1016+
m_document->Remove(m_cursor, pos.offset(), 1, 0);
10151017
}
10161018

10171019
} else {

3rdparty/QHexView/qhexview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class QHexView : public QAbstractScrollArea {
112112
public slots:
113113
void setDocument(const QSharedPointer<QHexDocument> &document,
114114
QHexCursor *cursor = nullptr);
115+
void resetDocument();
115116
bool RemoveSelection(int nibbleindex = 1);
116117
bool removeSelection();
117118

3rdparty/WingCodeEdit

ShareMemoryDrv/lang/shmem_zh_CN.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
<translation>一个提供羽云十六进制编辑器2的插件打开共享内存的驱动</translation>
1515
</message>
1616
<message>
17-
<location filename="../sharememorydrv.cpp" line="56"/>
17+
<location filename="../sharememorydrv.cpp" line="53"/>
1818
<source>ShareMemory</source>
1919
<translation>共享内存</translation>
2020
</message>
2121
<message>
22-
<location filename="../sharememorydrv.cpp" line="65"/>
22+
<location filename="../sharememorydrv.cpp" line="62"/>
2323
<source>SharedMemory</source>
2424
<translation>共享内存</translation>
2525
</message>
2626
<message>
27-
<location filename="../sharememorydrv.cpp" line="65"/>
27+
<location filename="../sharememorydrv.cpp" line="62"/>
2828
<source>PleaseInputID:</source>
2929
<translation>请输入标识:</translation>
3030
</message>

ShareMemoryDrv/sharedmemory.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ qint64 SharedMemory::readData(char *data, qint64 maxSize) {
7979
return -1;
8080
}
8181

82+
auto pos = this->pos();
8283
const char *sharedMemoryData =
83-
static_cast<const char *>(m_sharedMemory.constData());
84+
static_cast<const char *>(m_sharedMemory.constData()) + pos;
8485

8586
// Copy the data from shared memory
86-
qint64 dataSize = qMin(maxSize, m_sharedMemory.size());
87+
qint64 dataSize = qMin(maxSize, m_sharedMemory.size() - pos);
8788
memcpy(data, sharedMemoryData, dataSize);
8889

8990
return dataSize;
@@ -98,15 +99,11 @@ qint64 SharedMemory::writeData(const char *data, qint64 maxSize) {
9899
return -1;
99100
}
100101

101-
// Ensure the shared memory is large enough
102-
if (maxSize > m_sharedMemory.size()) {
103-
qWarning() << "Data exceeds shared memory size.";
104-
return -1;
105-
}
106-
107102
// Copy data to the shared memory
108-
char *sharedMemoryData = static_cast<char *>(m_sharedMemory.data());
109-
memcpy(sharedMemoryData, data, maxSize);
103+
auto pos = this->pos();
104+
char *sharedMemoryData = static_cast<char *>(m_sharedMemory.data()) + pos;
105+
qint64 dataSize = qMin(maxSize, m_sharedMemory.size() - pos);
106+
memcpy(sharedMemoryData, data, dataSize);
110107

111108
return maxSize;
112109
}

ShareMemoryDrv/sharememorydrv.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ WingHex::WingIODevice *SharedMemoryDriver::onOpenFile(const QString &path) {
4545
}
4646

4747
bool SharedMemoryDriver::onCloseFile(WingHex::WingIODevice *dev) {
48-
if (dev->isOpen()) {
49-
dev->close();
50-
}
51-
dev->deleteLater();
48+
dev->close();
5249
return true;
5350
}
5451

TestPlugin/lang/TestPlugin_zh_CN.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@
308308
<location filename="../testplugin.cpp" line="260"/>
309309
<location filename="../testplugin.cpp" line="286"/>
310310
<location filename="../testplugin.cpp" line="294"/>
311-
<location filename="../testplugin.cpp" line="302"/>
312-
<location filename="../testplugin.cpp" line="310"/>
313-
<location filename="../testplugin.cpp" line="319"/>
314-
<location filename="../testplugin.cpp" line="326"/>
311+
<location filename="../testplugin.cpp" line="301"/>
312+
<location filename="../testplugin.cpp" line="309"/>
313+
<location filename="../testplugin.cpp" line="318"/>
314+
<location filename="../testplugin.cpp" line="325"/>
315315
<source>InvalidParamsCount</source>
316316
<translation>无效参数个数</translation>
317317
</message>

0 commit comments

Comments
 (0)