summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qxpmhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image/qxpmhandler.cpp')
-rw-r--r--src/gui/image/qxpmhandler.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index aabee7fcd7..50f9f035a6 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -15,12 +15,15 @@
#include <private/qcolor_p.h>
#include <private/qduplicatetracker_p.h> // for easier std::pmr detection
+#include <private/qtools_p.h>
#include <algorithm>
#include <array>
QT_BEGIN_NAMESPACE
+using namespace QtMiscUtils;
+
Q_DECLARE_LOGGING_CATEGORY(lcImageIo)
static quint64 xpmHash(const QString &str)
@@ -736,15 +739,13 @@ static QString fbname(const QString &fileName) // get file basename (sort of)
int i = qMax(s.lastIndexOf(u'/'), s.lastIndexOf(u'\\'));
if (i < 0)
i = 0;
- auto isAsciiLetterOrNumber = [](QChar ch) -> bool {
- return (ch.unicode() >= '0' && ch.unicode() <= '9') ||
- (ch.unicode() >= 'A' && ch.unicode() <= 'Z') ||
- (ch.unicode() >= 'a' && ch.unicode() <= 'z') ||
- ch.unicode() == '_';
+ auto checkChar = [](QChar ch) -> bool {
+ uchar uc = ch.unicode();
+ return isAsciiLetterOrNumber(uc) || uc == '_';
};
int start = -1;
- for (; i < s.length(); ++i) {
- if (isAsciiLetterOrNumber(s.at(i))) {
+ for (; i < s.size(); ++i) {
+ if (checkChar(s.at(i))) {
start = i;
} else if (start > 0)
break;
@@ -898,8 +899,8 @@ static bool read_xpm_body(
}
} else {
QRgb c_rgb = 0;
- if (((buf.length()-1) % 3) && (buf[0] == '#')) {
- buf.truncate(((buf.length()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick
+ if (((buf.size()-1) % 3) && (buf[0] == '#')) {
+ buf.truncate(((buf.size()-1) / 4 * 3) + 1); // remove alpha channel left by imagemagick
}
if (buf[0] == '#') {
c_rgb = qt_get_hex_rgb(buf).value_or(0);
@@ -932,7 +933,7 @@ static bool read_xpm_body(
if (image.depth() == 8) {
uchar *p = image.scanLine(y);
uchar *d = (uchar *)buf.data();
- uchar *end = d + buf.length();
+ uchar *end = d + buf.size();
int x;
if (cpp == 1) {
char b[2];
@@ -958,7 +959,7 @@ static bool read_xpm_body(
} else {
QRgb *p = (QRgb*)image.scanLine(y);
uchar *d = (uchar *)buf.data();
- uchar *end = d + buf.length();
+ uchar *end = d + buf.size();
int x;
char b[16];
b[cpp] = '\0';