mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-13 13:32:53 +08:00
fix: can't resotre i2c decoder from data file
This commit is contained in:
parent
9264bce374
commit
bb06d1cccd
@ -81,8 +81,9 @@ QJsonArray File::get_decoders()
|
||||
ZipReader rd(f_name.c_str());
|
||||
auto *data = rd.GetInnterFileData("decoders");
|
||||
|
||||
if (data != NULL){
|
||||
QString jsonStr(data->data());
|
||||
if (data != NULL){
|
||||
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
|
||||
QString jsonStr(raw_bytes.data());
|
||||
QByteArray qbs = jsonStr.toUtf8();
|
||||
QJsonDocument sessionDoc = QJsonDocument::fromJson(qbs, &error);
|
||||
|
||||
@ -108,8 +109,9 @@ QJsonDocument File::get_session()
|
||||
auto *data = rd.GetInnterFileData("session");
|
||||
|
||||
if (data != NULL){
|
||||
QString jsonStr(data->data());
|
||||
QByteArray qbs = jsonStr.toUtf8();
|
||||
QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
|
||||
QString jsonStr(raw_bytes.data());
|
||||
QByteArray qbs = jsonStr.toUtf8();
|
||||
sessionDoc = QJsonDocument::fromJson(qbs, &error);
|
||||
|
||||
if (error.error != QJsonParseError::NoError){
|
||||
|
@ -1266,8 +1266,7 @@ bool MainWindow::on_store_session(QString name)
|
||||
QJsonObject sessionVar;
|
||||
if (!gen_session_json(sessionVar))
|
||||
return false;
|
||||
QJsonDocument sessionDoc(sessionVar);
|
||||
//sessionFile.write(QString::fromUtf8(sessionDoc.toJson()));
|
||||
QJsonDocument sessionDoc(sessionVar);
|
||||
outStream << QString::fromUtf8(sessionDoc.toJson());
|
||||
sessionFile.close();
|
||||
return true;
|
||||
@ -1280,7 +1279,7 @@ bool MainWindow::genSessionData(std::string &str)
|
||||
return false;
|
||||
QJsonDocument sessionDoc(sessionVar);
|
||||
QString data = QString::fromUtf8(sessionDoc.toJson());
|
||||
str.append(data.toLatin1().data());
|
||||
str.append(data.toLocal8Bit().data());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -60,8 +60,8 @@
|
||||
#include "dsvdef.h"
|
||||
#include "utility/encoding.h"
|
||||
#include "utility/path.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "log.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace pv {
|
||||
|
||||
@ -875,8 +875,8 @@ bool StoreSession::decoders_gen(std::string &str)
|
||||
if (!json_decoders(dec_array))
|
||||
return false;
|
||||
QJsonDocument sessionDoc(dec_array);
|
||||
QString data = QString::fromUtf8(sessionDoc.toJson());
|
||||
str.append(data.toLatin1().data());
|
||||
QString data = QString::fromUtf8(sessionDoc.toJson());
|
||||
str = std::string(data.toLocal8Bit().data());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -952,7 +952,7 @@ bool StoreSession::json_decoders(QJsonArray &array)
|
||||
auto rows = stack->get_rows_gshow();
|
||||
for (auto i = rows.begin(); i != rows.end(); i++) {
|
||||
pv::data::decode::Row _row = (*i).first;
|
||||
QString kn(_row.title().toUtf8().data());
|
||||
QString kn = _row.title();
|
||||
show_obj[kn] = QJsonValue::fromVariant((*i).second);
|
||||
}
|
||||
dec_obj["show"] = show_obj;
|
||||
|
@ -36,8 +36,9 @@ namespace encoding{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
stream.setEncoding(QStringConverter::Utf8);
|
||||
#else
|
||||
QTextCodec *code = QTextCodec::codecForName("UTF-8");
|
||||
stream.setCodec(code);
|
||||
//QTextCodec *code = QTextCodec::codecForName("UTF-8");
|
||||
// stream.setCodec(code);
|
||||
stream.setCodec("UTF-8");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user