aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk
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
parent0214e4f5d75e438239a2766699edafb927dde70b (diff)
downloadscintilla-mirror-01a7267cedd51d72bebb79a3ebe017541f0a3d12.tar.gz
Avoid C-style cast and range reduction warnings from cppcheck 2.8.
Diffstat (limited to 'gtk')
-rwxr-xr-xgtk/PlatGTK.cxx18
-rwxr-xr-xgtk/ScintillaGTK.cxx6
-rw-r--r--gtk/ScintillaGTKAccessible.cxx8
3 files changed, 15 insertions, 17 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);
}
}
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 6bdc09a7d..a256c484b 100755
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -3231,9 +3231,9 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS *object_class, GtkWidgetClass *widget_
static void scintilla_class_init(ScintillaClass *klass) {
try {
- OBJECT_CLASS *object_class = (OBJECT_CLASS *) klass;
- GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
- GtkContainerClass *container_class = (GtkContainerClass *) klass;
+ OBJECT_CLASS *object_class = reinterpret_cast<OBJECT_CLASS *>(klass);
+ GtkWidgetClass *widget_class = reinterpret_cast<GtkWidgetClass *>(klass);
+ GtkContainerClass *container_class = reinterpret_cast<GtkContainerClass *>(klass);
const GSignalFlags sigflags = static_cast<GSignalFlags>(G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST);
scintilla_signals[COMMAND_SIGNAL] = g_signal_new(
diff --git a/gtk/ScintillaGTKAccessible.cxx b/gtk/ScintillaGTKAccessible.cxx
index 3e234ae2c..ae6b0fb35 100644
--- a/gtk/ScintillaGTKAccessible.cxx
+++ b/gtk/ScintillaGTKAccessible.cxx
@@ -188,7 +188,7 @@ gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Sci::Position startByte, Sci::Po
// like TargetAsUTF8, but avoids a double conversion
if (sci->IsUnicodeMode() || ! *(charSetBuffer = sci->CharacterSetID())) {
int len = endByte - startByte;
- utf8Text = (char *) g_malloc(len + 1);
+ utf8Text = static_cast<gchar *>(g_malloc(len + 1));
sci->pdoc->GetCharRange(utf8Text, startByte, len);
utf8Text[len] = '\0';
} else {
@@ -196,7 +196,7 @@ gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Sci::Position startByte, Sci::Po
std::string s = sci->RangeText(startByte, endByte);
std::string tmputf = ConvertText(&s[0], s.length(), "UTF-8", charSetBuffer, false);
size_t len = tmputf.length();
- utf8Text = (char *) g_malloc(len + 1);
+ utf8Text = static_cast<gchar *>(g_malloc(len + 1));
memcpy(utf8Text, tmputf.c_str(), len);
utf8Text[len] = '\0';
}
@@ -1085,11 +1085,11 @@ static GType scintilla_object_accessible_get_type(GType parent_type G_GNUC_UNUSE
static AtkObject *scintilla_object_accessible_new(GType parent_type, GObject *obj) {
g_return_val_if_fail(SCINTILLA_IS_OBJECT(obj), nullptr);
- AtkObject *accessible = (AtkObject *) g_object_new(scintilla_object_accessible_get_type(parent_type),
+ AtkObject *accessible = static_cast<AtkObject *>(g_object_new(scintilla_object_accessible_get_type(parent_type),
#if HAVE_WIDGET_SET_UNSET
"widget", obj,
#endif
- nullptr);
+ nullptr));
atk_object_initialize(accessible, obj);
return accessible;