Skip to content

Commit

Permalink
Treat compilation warnings as errors
Browse files Browse the repository at this point in the history
So we do not miss newly added warnings.
Silence all deprecation warnings.
Fix existing warnings.
  • Loading branch information
qarkai committed Jan 30, 2025
1 parent d827723 commit bf4591d
Show file tree
Hide file tree
Showing 23 changed files with 100 additions and 79 deletions.
5 changes: 1 addition & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ project(
version : run_command('./version.sh', check : true).stdout().strip(),
license : ['GPL-2.0-or-later'],
meson_version : '>=1.0.0',
default_options : ['cpp_std=c++14', 'warning_level=3', 'buildtype=debugoptimized', 'cpp_link_args=-rdynamic']
default_options : ['cpp_std=c++14', 'warning_level=3', 'buildtype=debugoptimized', 'cpp_link_args=-rdynamic', 'werror=true']
)

# To inhibit warnings from the generated file icons.h
add_global_arguments('-Wno-overlength-strings', language : 'c')

# To compile originally-C files as C++
add_global_arguments('-Wno-error=deprecated-declarations', language : 'cpp')

# To enable debug statements in all files
add_global_arguments('-include', 'debug.h', language : 'cpp')

Expand Down
2 changes: 1 addition & 1 deletion src/collect-table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2396,7 +2396,7 @@ static void collection_table_cell_data_cb(GtkTreeViewColumn *, GtkCellRenderer *

info = static_cast<CollectInfo *>(g_list_nth_data(list, cd->number));

style = gtk_widget_get_style(ct->listview);
style = gq_gtk_widget_get_style(ct->listview);
if (info && (info->flag_mask & SELECTION_SELECTED) )
{
convert_gdkcolor_to_gdkrgba(&style->text[GTK_STATE_SELECTED], &color_fg);
Expand Down
7 changes: 5 additions & 2 deletions src/command-line-handling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,9 @@ void gq_log_file(GtkApplication *, GApplicationCommandLine *, GVariantDict *comm
command_line->ssi = secure_open(pathl);
}

#if HAVE_LUA
void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *command_line_options_dict, GList *)
{
#if HAVE_LUA
const gchar *text;
g_variant_dict_lookup(command_line_options_dict, "lua", "&s", &text);

Expand All @@ -891,10 +891,13 @@ void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVarian
{
g_application_command_line_print(app_command_line, _("lua error: no data\n"));
}
}
#else
void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *, GList *)
{
g_application_command_line_print(app_command_line, _("Lua is not available\n"));
#endif
}
#endif

void gq_new_window(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *, GList *)
{
Expand Down
31 changes: 30 additions & 1 deletion src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,17 @@

void gq_gtk_container_add(GtkWidget *container, GtkWidget *widget);

// Hide deprecation warnings
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
// Hide GtkAction deprecation warnings
// @todo Remove after porting to GAction/GMenu
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
inline gboolean GQ_GTK_IS_RADIO_ACTION(GtkAction *action) { return GTK_IS_RADIO_ACTION(action); }
inline gboolean GQ_GTK_IS_TOGGLE_ACTION(GtkAction *action) { return GTK_IS_TOGGLE_ACTION(action); }
const auto gq_gtk_action_activate = gtk_action_activate;
const auto gq_gtk_action_create_icon = gtk_action_create_icon;
const auto gq_gtk_action_get_accel_path = gtk_action_get_accel_path;
const auto gq_gtk_action_get_icon_name = gtk_action_get_icon_name;
const auto gq_gtk_action_get_label = gtk_action_get_label;
const auto gq_gtk_action_get_name = gtk_action_get_name;
const auto gq_gtk_action_get_stock_id = gtk_action_get_stock_id;
const auto gq_gtk_action_get_tooltip = gtk_action_get_tooltip;
Expand Down Expand Up @@ -101,6 +103,33 @@ const auto gq_gtk_ui_manager_new_merge_id = gtk_ui_manager_new_merge_id;
const auto gq_gtk_ui_manager_remove_action_group = gtk_ui_manager_remove_action_group;
const auto gq_gtk_ui_manager_remove_ui = gtk_ui_manager_remove_ui;
const auto gq_gtk_ui_manager_set_add_tearoffs = gtk_ui_manager_set_add_tearoffs;

// Hide other Gdk/Gtk deprecation warnings
const auto gq_gdk_cairo_create = gdk_cairo_create;
const auto gq_gdk_flush = gdk_flush;
const auto gq_gdk_keyboard_grab = gdk_keyboard_grab;
const auto gq_gdk_keyboard_ungrab = gdk_keyboard_ungrab;
const auto gq_gdk_pointer_grab = gdk_pointer_grab;
const auto gq_gdk_pointer_is_grabbed = gdk_pointer_is_grabbed;
const auto gq_gdk_pointer_ungrab = gdk_pointer_ungrab;
const auto gq_gdk_screen_get_height = gdk_screen_get_height;
const auto gq_gdk_screen_get_monitor_at_window = gdk_screen_get_monitor_at_window;
const auto gq_gdk_screen_get_width = gdk_screen_get_width;
const auto gq_gdk_screen_height = gdk_screen_height;
const auto gq_gdk_screen_width = gdk_screen_width;
const auto gq_gtk_icon_factory_add = gtk_icon_factory_add;
const auto gq_gtk_icon_factory_add_default = gtk_icon_factory_add_default;
const auto gq_gtk_icon_factory_new = gtk_icon_factory_new;
const auto gq_gtk_icon_set_new_from_pixbuf = gtk_icon_set_new_from_pixbuf;
const auto gq_gtk_image_menu_item_new_with_mnemonic = gtk_image_menu_item_new_with_mnemonic;
const auto gq_gtk_image_menu_item_set_image = gtk_image_menu_item_set_image;
const auto gq_gtk_image_new_from_stock = gtk_image_new_from_stock;
const auto gq_gtk_style_context_get_background_color = gtk_style_context_get_background_color;
const auto gq_gtk_widget_get_requisition = gtk_widget_get_requisition;
const auto gq_gtk_widget_get_style = gtk_widget_get_style;
const auto gq_gtk_widget_set_double_buffered = gtk_widget_set_double_buffered;
const auto gq_gtk_widget_size_request = gtk_widget_size_request;
const auto gq_gtk_window_parse_geometry = gtk_window_parse_geometry;
G_GNUC_END_IGNORE_DEPRECATIONS

#endif /* COMPAT_H */
Expand Down
2 changes: 1 addition & 1 deletion src/dupe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3893,7 +3893,7 @@ static GdkRGBA *dupe_listview_color_shifted(GtkWidget *widget)
{
GtkStyle *style;

style = gtk_widget_get_style(widget);
style = gq_gtk_widget_get_style(widget);
convert_gdkcolor_to_gdkrgba(&style->base[GTK_STATE_NORMAL], &color);

shift_color(&color, -1, 0);
Expand Down
8 changes: 4 additions & 4 deletions src/fullscreen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ GdkRectangle get_screen_default_geometry(GdkScreen *screen)

geometry.x = 0;
geometry.y = 0;
geometry.width = gdk_screen_get_width(screen);
geometry.height = gdk_screen_get_height(screen);
geometry.width = gq_gdk_screen_get_width(screen);
geometry.height = gq_gdk_screen_get_height(screen);

return geometry;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ GdkRectangle fullscreen_prefs_get_geometry(gint screen_num, GtkWidget *widget, G
same_region = (!widget || !gtk_widget_get_window(widget) ||
(dest_screen == gtk_widget_get_screen(widget) &&
(it->number%100 == 0 ||
it->number%100 == gdk_screen_get_monitor_at_window(dest_screen, gtk_widget_get_window(widget)) + 1)));
it->number%100 == gq_gdk_screen_get_monitor_at_window(dest_screen, gtk_widget_get_window(widget)) + 1)));
return it->geometry;
}
}
Expand Down Expand Up @@ -582,7 +582,7 @@ void fullscreen_stop(FullScreenData *fs)

fullscreen_hide_mouse_disable(fs);
fullscreen_busy_mouse_disable(fs);
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
gq_gdk_keyboard_ungrab(GDK_CURRENT_TIME);

if (fs->same_region)
{
Expand Down
2 changes: 1 addition & 1 deletion src/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,7 @@ void image_background_set_color_from_options(ImageWindow *imd, gboolean fullscre
if (!layout_valid(&lw)) return;

style_context = gtk_widget_get_style_context(lw->window);
gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);
gq_gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);

theme_color.red = bg_color.red * 1;
theme_color.green = bg_color.green * 1;
Expand Down
4 changes: 2 additions & 2 deletions src/img-view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ static ViewWindow *real_view_window_new(FileData *fd, GList *list, CollectionDat

if (options->image.limit_window_size)
{
gint mw = gdk_screen_width() * options->image.max_window_size / 100;
gint mh = gdk_screen_height() * options->image.max_window_size / 100;
gint mw = gq_gdk_screen_width() * options->image.max_window_size / 100;
gint mh = gq_gdk_screen_height() * options->image.max_window_size / 100;

w = std::min(w, mw);
h = std::min(h, mh);
Expand Down
4 changes: 2 additions & 2 deletions src/layout-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ static void layout_actions_setup_editors(LayoutWindow *lw)
GtkWidget *image = nullptr;
if (editor->icon)
{
image = gtk_image_new_from_stock(editor->key, GTK_ICON_SIZE_BUTTON);
image = gq_gtk_image_new_from_stock(editor->key, GTK_ICON_SIZE_BUTTON);
}
else
{
Expand Down Expand Up @@ -3438,7 +3438,7 @@ void layout_toolbar_add(LayoutWindow *lw, ToolbarType type, const gchar *action_
/** @FIXME Using tootip as a flag to layout_actions_setup_editors()
* is not a good way.
*/
tooltip_text = gtk_action_get_label(action);
tooltip_text = gq_gtk_action_get_label(action);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,7 @@ LayoutWindow *layout_new_with_geometry(FileData *dir_fd, LayoutOptions *lop,

if (geometry)
{
if (!gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry))
if (!gq_gtk_window_parse_geometry(GTK_WINDOW(lw->window), geometry))
{
log_printf("%s", _("Invalid geometry\n"));
}
Expand Down
22 changes: 4 additions & 18 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
#include "collect-io.h"
#include "collect.h"
#include "command-line-handling.h"
#include "compat.h"
#include "exif.h"
#include "filedata.h"
#include "filefilter.h"
Expand Down Expand Up @@ -197,6 +198,7 @@ GOptionEntry command_line_options_cache_maintenance[] =
{ nullptr , 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE , nullptr, nullptr , nullptr },
};

#if !HAVE_DEVELOPER
#if defined(SA_SIGINFO)
void sig_handler_cb(int signo, siginfo_t *info, void *)
{
Expand Down Expand Up @@ -321,6 +323,7 @@ void sig_handler_cb(int)
exit(EXIT_FAILURE);
}
#endif /* defined(SA_SIGINFO) */
#endif /* !HAVE_DEVELOPER */

gboolean search_command_line_for_option(const gint argc, const gchar* const argv[], const gchar* option_name)
{
Expand Down Expand Up @@ -395,23 +398,6 @@ void quit_activated_cb(GSimpleAction *, GVariant *, gpointer app)
g_application_quit(G_APPLICATION(app));
}

gboolean parse_command_line_for_cache_maintenance_option(gint argc, gchar *argv[])
{
const gchar *cache_maintenance_option = "--cache-maintenance=";
const gint len = strlen(cache_maintenance_option);

if (argc >= 2)
{
const gchar *cmd_line = argv[1];
if (strncmp(cmd_line, cache_maintenance_option, len) == 0)
{
return TRUE;
}
}

return FALSE;
}

/*
*-----------------------------------------------------------------------------
* startup, init, and exit
Expand Down Expand Up @@ -752,7 +738,7 @@ void set_theme_bg_color()
lw = static_cast<LayoutWindow *>(work->data);

style_context = gtk_widget_get_style_context(lw->window);
gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);
gq_gtk_style_context_get_background_color(style_context, GTK_STATE_FLAG_NORMAL, &bg_color);

theme_color.red = bg_color.red ;
theme_color.green = bg_color.green ;
Expand Down
23 changes: 12 additions & 11 deletions src/pixbuf-renderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <cstdlib>
#include <cstring>

#include "compat.h"
#include "main-defines.h"
#include "misc.h"
#include "options.h"
Expand Down Expand Up @@ -446,7 +447,7 @@ static void pixbuf_renderer_init(PixbufRenderer *pr)

pr->renderer2 = nullptr;

gtk_widget_set_double_buffered(box, FALSE);
gq_gtk_widget_set_double_buffered(box, FALSE);
gtk_widget_set_app_paintable(box, TRUE);
g_signal_connect_after(G_OBJECT(box), "size_allocate",
G_CALLBACK(pr_size_cb), pr);
Expand Down Expand Up @@ -641,8 +642,8 @@ static gboolean pr_parent_window_resize(PixbufRenderer *pr, gint w, gint h)

if (pr->window_limit)
{
gint sw = gdk_screen_width() * pr->window_limit_size / 100;
gint sh = gdk_screen_height() * pr->window_limit_size / 100;
gint sw = gq_gdk_screen_width() * pr->window_limit_size / 100;
gint sh = gq_gdk_screen_height() * pr->window_limit_size / 100;

w = std::min(w, sw);
h = std::min(h, sh);
Expand Down Expand Up @@ -1615,8 +1616,8 @@ static gboolean pr_zoom_clamp(PixbufRenderer *pr, gdouble zoom,

if (sizeable)
{
max_w = gdk_screen_width();
max_h = gdk_screen_height();
max_w = gq_gdk_screen_width();
max_h = gq_gdk_screen_height();

if (pr->window_limit)
{
Expand Down Expand Up @@ -1997,7 +1998,7 @@ static gboolean pr_mouse_motion_cb(GtkWidget *widget, GdkEventMotion *event, gpo
pr->y_mouse = event->y;
pr_update_pixel_signal(pr);

if (!pr->in_drag || !gdk_pointer_is_grabbed()) return FALSE;
if (!pr->in_drag || !gq_gdk_pointer_is_grabbed()) return FALSE;

if (pr->drag_moved < PR_DRAG_SCROLL_THRESHHOLD)
{
Expand Down Expand Up @@ -2064,9 +2065,9 @@ static gboolean pr_mouse_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpo
pr->drag_last_x = bevent->x;
pr->drag_last_y = bevent->y;
pr->drag_moved = 0;
gdk_pointer_grab(gtk_widget_get_window(widget), FALSE,
static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK),
nullptr, nullptr, bevent->time);
gq_gdk_pointer_grab(gtk_widget_get_window(widget), FALSE,
static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_RELEASE_MASK),
nullptr, nullptr, bevent->time);
gtk_grab_add(widget);
break;
case MOUSE_BUTTON_MIDDLE:
Expand Down Expand Up @@ -2100,10 +2101,10 @@ static gboolean pr_mouse_release_cb(GtkWidget *widget, GdkEventButton *bevent, g
return TRUE;
}

if (gdk_pointer_is_grabbed() && gtk_widget_has_grab(GTK_WIDGET(pr)))
if (gq_gdk_pointer_is_grabbed() && gtk_widget_has_grab(GTK_WIDGET(pr)))
{
gtk_grab_remove(widget);
gdk_pointer_ungrab(bevent->time);
gq_gdk_pointer_ungrab(bevent->time);
widget_set_cursor(widget, -1);
}

Expand Down
9 changes: 5 additions & 4 deletions src/pixbuf-util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

#include <config.h>

#include "compat.h"
#include "exif.h"
#include "filedata.h"
#include "main-defines.h"
Expand Down Expand Up @@ -233,13 +234,13 @@ static void register_stock_icon(const gchar *key, GdkPixbuf *pixbuf)
{
static GtkIconFactory *icon_factory = []()
{
GtkIconFactory *icon_factory = gtk_icon_factory_new();
gtk_icon_factory_add_default(icon_factory);
GtkIconFactory *icon_factory = gq_gtk_icon_factory_new();
gq_gtk_icon_factory_add_default(icon_factory);
return icon_factory;
}();

GtkIconSet *icon_set = gtk_icon_set_new_from_pixbuf(pixbuf);
gtk_icon_factory_add(icon_factory, key, icon_set);
GtkIconSet *icon_set = gq_gtk_icon_set_new_from_pixbuf(pixbuf);
gq_gtk_icon_factory_add(icon_factory, key, icon_set);
}


Expand Down
3 changes: 2 additions & 1 deletion src/renderer-tiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <glib.h>
#include <gtk/gtk.h>

#include "compat.h"
#include "options.h"
#include "pixbuf-renderer.h"
#include "typedefs.h"
Expand Down Expand Up @@ -573,7 +574,7 @@ void rt_overlay_draw(RendererTiles *rt, GdkRectangle request_rect, ImageTile *it
cairo_fill(cr);
cairo_destroy (cr);

cr = gdk_cairo_create(od->window);
cr = gq_gdk_cairo_create(od->window);
cairo_set_source_surface(cr, rt->overlay_buffer, r.x - od_rect.x, r.y - od_rect.y);
cairo_rectangle (cr, r.x - od_rect.x, r.y - od_rect.y, r.width, r.height);
cairo_fill (cr);
Expand Down
2 changes: 1 addition & 1 deletion src/toolbar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static void toolbarlist_add_button(const gchar *name, const gchar *label,
}
else
{
image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON);
image = gq_gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_BUTTON);
}
}
else
Expand Down
3 changes: 2 additions & 1 deletion src/ui-fileops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint m
{
/* Ignores chown errors, while still doing chown
(so root still can copy files preserving ownership) */
chown(tl, st.st_uid, st.st_gid);
int err = chown(tl, st.st_uid, st.st_gid);
(void)err; // @todo Use [[maybe_unused]] since C++17

if (chmod(tl, st.st_mode) < 0)
{
Expand Down
Loading

0 comments on commit bf4591d

Please sign in to comment.