Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/CMakeLists.txt b/CMakeLists.txt
- index df655fbf..8d2a5bbb 100644
- --- a/CMakeLists.txt
- +++ b/CMakeLists.txt
- @@ -52,7 +52,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
- if(BUILD_WITH_QT6)
- set(QT_MAJOR_VERSION 6)
- message(STATUS "Building Qt 6 version")
- - find_package(Qt6 COMPONENTS Core Test Core5Compat REQUIRED)
- + find_package(Qt6 COMPONENTS Core Test REQUIRED)#Core5Compat REQUIRED)
- else()
- set(QT_MAJOR_VERSION 5)
- message(STATUS "Building Qt 5 version")
- diff --git a/QcaConfig.cmake.in b/QcaConfig.cmake.in
- index ce9a8ab2..3975ac3e 100644
- --- a/QcaConfig.cmake.in
- +++ b/QcaConfig.cmake.in
- @@ -3,9 +3,9 @@
- include(CMakeFindDependencyMacro)
- find_dependency(Qt@QT_MAJOR_VERSION@Core)
- -if (@QT_MAJOR_VERSION@ EQUAL 6 AND NOT @BUILD_SHARED_LIBRARIES@)
- - find_dependency(Qt@QT_MAJOR_VERSION@Core5Compat)
- -endif()
- +#if (@QT_MAJOR_VERSION@ EQUAL 6 AND NOT @BUILD_SHARED_LIBRARIES@)
- +# find_dependency(Qt@QT_MAJOR_VERSION@Core5Compat)
- +#endif()
- if(NOT TARGET @QCA_LIB_NAME@)
- include("${CMAKE_CURRENT_LIST_DIR}/@QCA_CONFIG_NAME_BASE@Targets.cmake")
- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
- index 03a03a33..a2bfa8f4 100644
- --- a/src/CMakeLists.txt
- +++ b/src/CMakeLists.txt
- @@ -126,7 +126,7 @@ SET( SOURCES ${SOURCES} ${botan_SOURCES})
- add_library(${QCA_LIB_NAME} ${SOURCES} ${public_HEADERS})
- target_link_libraries(${QCA_LIB_NAME} PUBLIC Qt${QT_MAJOR_VERSION}::Core)
- if(BUILD_WITH_QT6)
- - target_link_libraries(${QCA_LIB_NAME} PRIVATE Qt6::Core5Compat)
- + #target_link_libraries(${QCA_LIB_NAME} PRIVATE Qt6::Core5Compat)
- endif()
- if(WIN32)
- diff --git a/src/support/qpipe.cpp b/src/support/qpipe.cpp
- index 122e96a8..e7efe140 100644
- --- a/src/support/qpipe.cpp
- +++ b/src/support/qpipe.cpp
- @@ -36,9 +36,14 @@
- #ifdef Q_OS_WIN
- #include <QMutex>
- +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- #include <QTextCodec>
- #include <QTextDecoder>
- #include <QTextEncoder>
- +#else
- +# include <QStringEncoder>
- +# include <QStringDecoder>
- +#endif
- #include <QThread>
- #include <QWaitCondition>
- #else
- @@ -298,7 +303,11 @@ static int pipe_read_avail_console(Q_PIPE_ID pipe)
- }
- // pass dec to keep a long-running decoder, else 0
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, QTextDecoder *dec = 0)
- +#else
- +static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, QStringDecoder decoder)
- +#endif
- {
- int n, size, count;
- bool own_decoder;
- @@ -314,12 +323,21 @@ static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, Q
- if (count == 0)
- return 0;
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- if (dec) {
- own_decoder = false;
- } else {
- dec = 0;
- own_decoder = true;
- }
- +#else
- + if(decoder.isValid()) {
- + own_decoder = false;
- + } else {
- + decoder = QStringDecoder(QStringDecoder::Utf8);
- + own_decoder = true;
- + }
- +#endif
- size = 0;
- for (n = 0; n < count && size < max; ++n) {
- @@ -333,7 +351,9 @@ static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, Q
- if (!ret) {
- // if the first read is an error, then report error
- if (n == 0) {
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- delete dec;
- +#endif
- return -1;
- }
- // if we have some data, don't count this as an error.
- @@ -346,7 +366,11 @@ static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, Q
- if (use_uni)
- substr = QChar(uni);
- else
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- substr = dec->toUnicode((const char *)&ansi, 1);
- +#else
- + substr = decoder(QByteArrayView((const char *)&ansi, 1));
- +#endif
- for (int k = 0; k < substr.length() && size < max; ++k) {
- QChar c = substr[k];
- @@ -360,7 +384,9 @@ static int pipe_read_console(Q_PIPE_ID pipe, ushort *data, int max, bool *eof, Q
- }
- }
- if (own_decoder)
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- delete dec;
- +#endif
- return size;
- }
- @@ -886,7 +912,9 @@ public:
- bool atEnd, atError, forceNotify;
- int readAhead;
- SafeTimer *readTimer;
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- QTextDecoder *dec;
- +#endif
- bool consoleMode;
- QPipeWriter *pipeWriter;
- QPipeReader *pipeReader;
- @@ -904,8 +932,10 @@ public:
- readTimer = 0;
- pipeWriter = 0;
- pipeReader = 0;
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- dec = 0;
- #endif
- +#endif
- #ifdef Q_OS_UNIX
- sn_read = nullptr;
- sn_write = nullptr;
- @@ -930,8 +960,10 @@ public:
- pipeWriter = 0;
- delete pipeReader;
- pipeReader = 0;
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- delete dec;
- dec = 0;
- +#endif
- consoleMode = false;
- #endif
- #ifdef Q_OS_UNIX
- @@ -972,11 +1004,12 @@ public:
- if (type == QPipeDevice::Read) {
- #ifdef Q_OS_WIN
- // for windows, the blocking mode is chosen by the QPipeReader
- -
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- // console might need a decoder
- if (consoleMode) {
- dec = 0;
- }
- +#endif
- // pipe reader
- #ifdef USE_POLL
- @@ -1268,16 +1301,38 @@ int QPipeDevice::read(char *data, int maxsize)
- #endif
- ushort *dest = (ushort *)destbuf.data();
- - ret = pipe_read_console(d->pipe, dest, num, &done, d->dec);
- + ret = pipe_read_console(d->pipe, dest, num, &done, QStringDecoder(QStringDecoder::Utf8));
- if (ret != -1) {
- // for security, encode one character at a time without
- // performing a QString conversion of the whole thing
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- QTextCodec *codec = QTextCodec::codecForMib(106);
- QTextCodec::ConverterState cstate(QTextCodec::IgnoreHeader);
- +#else
- + QStringEncoder encoder(QStringEncoder::Utf8);
- +#endif
- int at = 0;
- for (int n = 0; n < ret; ++n) {
- QChar c(dest[n]);
- +#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
- QByteArray out = codec->fromUnicode(&c, 1, &cstate);
- +#else
- + if (c.isHighSurrogate()) {
- + continue;
- + }
- + QByteArray out;
- + // looks ugly, but we don't keep strings in insecure containers
- + if (c.isLowSurrogate()) {
- + if (!n) continue; // ignore completely invaid surrogate
- + QChar chars[2] = {QChar{dest[n-1]}, QChar{dest[n]}};
- + if (!chars[0].isHighSurrogate()) continue; // another invalid surrogate
- + QStringView view{chars, 2};
- + out += QByteArray(encoder(view));
- + } else {
- + QStringView view(&c, 1);
- + out += QByteArray(encoder(view));
- + }
- +#endif
- memcpy(data + offset + at, out.data(), out.size());
- at += out.size();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement