From b764b210e90d463bb0e99ba4d0bcebe8bfd09cea Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Mon, 26 Sep 2022 17:31:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF=EF=BC=9B=E4=BF=AE=E5=A4=8D=E6=B5=AE?= =?UTF-8?q?=E7=82=B9=E5=9E=8B=E6=95=B0=E5=80=BC=E8=8E=B7=E5=8F=96BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/DlgPage.cpp | 6 +++--- sane/gb_json.cpp | 8 ++++++++ sane/scanner.cpp | 3 +++ twain/twain/huagaods.cpp | 10 +++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sane/DlgPage.cpp b/sane/DlgPage.cpp index 994149c..04cc8b3 100644 --- a/sane/DlgPage.cpp +++ b/sane/DlgPage.cpp @@ -889,10 +889,9 @@ void* dlg_page::value_from_ctrl(HWND ctrl, SANE_Value_Type* type) else if (cmpstr(cls, WC_EDITW) == 0 || cmpstr(cls, WC_COMBOBOXW) == 0) { int len = (int)GetPropW(host, dlg_page::property_size.c_str()); - wchar_t* buf = new wchar_t[len + 2]; + wchar_t* buf = new wchar_t[len + 8]; - GetWindowTextW(ctrl, buf, len); - buf[len] = 0; + GetWindowTextW(ctrl, buf, len + 6); if (tp == SANE_TYPE_INT) { ret = new char[sizeof(SANE_Int)]; @@ -905,6 +904,7 @@ void* dlg_page::value_from_ctrl(HWND ctrl, SANE_Value_Type* type) } else if (tp == SANE_TYPE_STRING) { + buf[len] = 0; std::string utf8(local_trans::u2a(buf, CP_UTF8)); ret = new char[len + 2]; if ((int)utf8.length() > len) diff --git a/sane/gb_json.cpp b/sane/gb_json.cpp index b7d5eb9..d4545c1 100644 --- a/sane/gb_json.cpp +++ b/sane/gb_json.cpp @@ -3,6 +3,8 @@ #include #include +#include "../../sdk/include/huagao/brand.h" + #if defined(WIN32) || defined(_WIN64) #define bzero(b, s) memset(b, 0, s) #endif @@ -1067,6 +1069,12 @@ namespace gb { if (jsn_) { + { + char ver[40] = { 0 }; + sprintf_s(ver, "%u.%u", VERSION_MAIN, VERSION_SUB); + jsn_->set_value("ver", ver); + } + std::string cont(jsn_->to_string(false)), encode(""); gb::base64 b64; diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 500fa54..c6f676e 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -979,6 +979,8 @@ EX_OPTION_HANDLER_IMPL(paper) int now = sane_opt_trans::paper_to_twain(buf), init = sane_opt_trans::paper_to_twain(def), val = 0; + + local_utility::free_memory(def); do { if (desc->constraint_type == SANE_CONSTRAINT_STRING_LIST) @@ -1176,6 +1178,7 @@ EX_OPTION_HANDLER_IMPL(duplex) setv(&val, VAL_ROLE_DEFAULT, data); } } + local_utility::free_memory(init); } else { diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index c0a76fc..31ab83e 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -444,6 +444,14 @@ static void copy_type(bool& to, Bool from) { to = (bool)from; } +static void copy_type(BYTE& to, bool from) +{ + to = from; +} +static void copy_type(bool& to, BYTE from) +{ + to = (bool)from; +} static void copy_type(UInt32& to, int from) { to = from; @@ -2683,7 +2691,7 @@ void huagao_ds::init_support_caps_ex(void) { \ if(type == VAL_TYPE_BOOL) \ { \ - SET_SANE_CAP(bool, Bool, name) \ + SET_SANE_CAP(bool, BYTE, name) \ } \ else if(type == VAL_TYPE_INT) \ { \