From ae04876dc774c338b4638f86ed7508d5457cffe7 Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Fri, 6 Jan 2023 15:34:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8E=8B=E5=8A=9B=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/base/test_base.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/code/base/test_base.cpp b/code/base/test_base.cpp index 3e0ec01..7196801 100644 --- a/code/base/test_base.cpp +++ b/code/base/test_base.cpp @@ -300,19 +300,24 @@ public: size_t l = 0; bool type = true; wchar_t buf[128] =L""; - int ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); - if (ret == ERROR_INSUFFICIENT_BUFFER) - { - wstr.resize(l); - ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); - } - if (ret == ERROR_INSUFFICIENT_BUFFER) + int ret = SCANNER_ERR_OK; + if (code != SANE_EVENT_IMAGE_OK) { - type = false; - - h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type); - return -1; + ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + wstr.resize(l); + ret = str_to_wchar((char*)data, (wchar_t*)wstr.c_str(), &l); + } + if (ret == ERROR_INSUFFICIENT_BUFFER) + { + type = false; + + h->test_callback(set_test_name_.c_str(), ui_helper::TEST_EVENT_RESULT, (void*)wstr.c_str(), type); + return -1; + } } + //std::string str = StringToUtf((char*)data); switch (code) {