Skip to content

Commit 7ba4484

Browse files
committed
fixed exception in file save function
1 parent 9b86131 commit 7ba4484

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/fhex.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,16 @@ void Fhex::saveDataToFile(string path, bool loadfile) {
11261126
this->hexEditor->getCurrentData().clear();
11271127
this->hexEditor->getCurrentData().shrink_to_fit();
11281128
//Now copy data from the front-end
1129-
this->hexEditor->getCurrentData().insert(this->hexEditor->getCurrentData().begin(), this->qhex->data().begin(), this->qhex->data().end());
1129+
try {
1130+
for(const char c : this->qhex->data()) {
1131+
this->hexEditor->getCurrentData().push_back(uint8_t(c));
1132+
}
1133+
} catch(const exception &e) {
1134+
this->statusBar.setText("SAVE ERROR! " + QString(e.what()));
1135+
return;
1136+
}
1137+
1138+
//
11301139
//Update the size, the user could have added/removed bytes
11311140
long diffbytes = this->hexEditor->getCurrentData().size() - this->hexEditor->loadedFileSize;
11321141
this->hexEditor->loadedFileSize = this->hexEditor->getCurrentData().size();

src/fhex.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <chrono>
4949
#include <thread>
5050
#include <future>
51+
#include <algorithm>
5152

5253
#include "core/json.h"
5354

@@ -78,7 +79,7 @@ class Fhex : public QMainWindow
7879

7980
private:
8081
// RELEASE VERSION
81-
string version = "3.0.4";
82+
string version = "3.0.5";
8283

8384
// JSON
8485
json jconfig;

0 commit comments

Comments
 (0)