aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk/PlatGTK.cxx
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2022-07-04 22:24:50 +1000
committerNeil Hodgson <nyamatongwe@gmail.com>2022-07-04 22:24:50 +1000
commit01a7267cedd51d72bebb79a3ebe017541f0a3d12 (patch)
tree51156a6eab01b80b0038f8b70bef9aa5ce6d4285 /gtk/PlatGTK.cxx
parent0214e4f5d75e438239a2766699edafb927dde70b (diff)
downloadscintilla-mirror-01a7267cedd51d72bebb79a3ebe017541f0a3d12.tar.gz
Avoid C-style cast and range reduction warnings from cppcheck 2.8.
Diffstat (limited to 'gtk/PlatGTK.cxx')
-rwxr-xr-xgtk/PlatGTK.cxx18
1 files changed, 8 insertions, 10 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index dde948453..87c57abcd 100755
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -775,12 +775,11 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, const Font *font_, XYPOSITION ybas
PenColourAlpha(fore);
const XYPOSITION xText = rc.left;
if (PFont(font_)->fd) {
- std::string utfForm;
if (et == EncodingType::utf8) {
LayoutSetText(layout.get(), text);
} else {
SetConverter(PFont(font_)->characterSet);
- utfForm = UTF8FromIconv(conv, text);
+ std::string utfForm = UTF8FromIconv(conv, text);
if (utfForm.empty()) { // iconv failed so treat as Latin1
utfForm = UTF8FromLatin1(text);
}
@@ -983,13 +982,12 @@ void SurfaceImpl::MeasureWidths(const Font *font_, std::string_view text, XYPOSI
XYPOSITION SurfaceImpl::WidthText(const Font *font_, std::string_view text) {
if (PFont(font_)->fd) {
- std::string utfForm;
pango_layout_set_font_description(layout.get(), PFont(font_)->fd.get());
if (et == EncodingType::utf8) {
LayoutSetText(layout.get(), text);
} else {
SetConverter(PFont(font_)->characterSet);
- utfForm = UTF8FromIconv(conv, text);
+ std::string utfForm = UTF8FromIconv(conv, text);
if (utfForm.empty()) { // iconv failed so treat as Latin1
utfForm = UTF8FromLatin1(text);
}
@@ -1365,7 +1363,7 @@ class ListBoxX : public ListBox {
WindowID frame;
WindowID list;
WindowID scroller;
- void *pixhash;
+ GHashTable *pixhash;
GtkCellRenderer *pixbuf_renderer;
GtkCellRenderer *renderer;
RGBAImageSet images;
@@ -1392,8 +1390,8 @@ public:
ListBoxX&operator=(ListBoxX&&) = delete;
~ListBoxX() noexcept override {
if (pixhash) {
- g_hash_table_foreach((GHashTable *) pixhash, list_image_free, nullptr);
- g_hash_table_destroy((GHashTable *) pixhash);
+ g_hash_table_foreach(pixhash, list_image_free, nullptr);
+ g_hash_table_destroy(pixhash);
}
if (widCached) {
gtk_widget_destroy(GTK_WIDGET(widCached));
@@ -1846,7 +1844,7 @@ static void init_pixmap(ListImage *list_image) noexcept {
void ListBoxX::Append(char *s, int type) {
ListImage *list_image = nullptr;
if ((type >= 0) && pixhash) {
- list_image = static_cast<ListImage *>(g_hash_table_lookup((GHashTable *) pixhash,
+ list_image = static_cast<ListImage *>(g_hash_table_lookup(pixhash,
GINT_TO_POINTER(type)));
}
GtkTreeIter iter {};
@@ -2007,7 +2005,7 @@ void ListBoxX::RegisterRGBA(int type, std::unique_ptr<RGBAImage> image) {
if (!pixhash) {
pixhash = g_hash_table_new(g_direct_hash, g_direct_equal);
}
- ListImage *list_image = static_cast<ListImage *>(g_hash_table_lookup((GHashTable *) pixhash,
+ ListImage *list_image = static_cast<ListImage *>(g_hash_table_lookup(pixhash,
GINT_TO_POINTER(type)));
if (list_image) {
// Drop icon already registered
@@ -2018,7 +2016,7 @@ void ListBoxX::RegisterRGBA(int type, std::unique_ptr<RGBAImage> image) {
} else {
list_image = g_new0(ListImage, 1);
list_image->rgba_data = observe;
- g_hash_table_insert((GHashTable *) pixhash, GINT_TO_POINTER(type),
+ g_hash_table_insert(pixhash, GINT_TO_POINTER(type),
(gpointer) list_image);
}
}