From 51c2c69357963ecaffba522aa963a3eba1c3bc8e Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sat, 5 Jun 2021 23:04:31 +0430 Subject: AK+Everywhere: Disallow constructing Functions from incompatible types Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story. --- Userland/Applications/FontEditor/FontEditor.cpp | 6 +++--- Userland/Applications/FontEditor/NewFontDialog.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Userland/Applications/FontEditor') diff --git a/Userland/Applications/FontEditor/FontEditor.cpp b/Userland/Applications/FontEditor/FontEditor.cpp index 7aae6efb87..f66c58c59b 100644 --- a/Userland/Applications/FontEditor/FontEditor.cpp +++ b/Userland/Applications/FontEditor/FontEditor.cpp @@ -92,7 +92,7 @@ static RefPtr create_font_preview_window(FontEditorWidget& editor) auto& reload_button = textbox_button_container.add(); reload_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png")); reload_button.set_fixed_width(22); - reload_button.on_click = [&] { + reload_button.on_click = [&](auto) { static int i = 1; if (i >= s_pangram_count) i = 0; @@ -326,7 +326,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& m_glyph_editor_scale_actions.add_action(*m_scale_fifteen_action); m_glyph_editor_scale_actions.set_exclusive(true); - move_glyph_button.on_click = [&] { + move_glyph_button.on_click = [&](auto) { if (move_glyph_button.is_checked()) m_glyph_editor_widget->set_mode(GlyphEditorWidget::Move); else @@ -407,7 +407,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& did_modify_font(); }; - m_weight_combobox->on_change = [this]() { + m_weight_combobox->on_change = [this](auto&, auto&) { m_edited_font->set_weight(GUI::name_to_weight(m_weight_combobox->text())); did_modify_font(); }; diff --git a/Userland/Applications/FontEditor/NewFontDialog.cpp b/Userland/Applications/FontEditor/NewFontDialog.cpp index b15127b279..5ca7d12565 100644 --- a/Userland/Applications/FontEditor/NewFontDialog.cpp +++ b/Userland/Applications/FontEditor/NewFontDialog.cpp @@ -197,7 +197,7 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window) m_glyph_width_spinbox->on_change = [&](int value) { preview_editor.set_preview_size(value, m_glyph_height_spinbox->value()); - deferred_invoke([&] { + deferred_invoke([&](auto&) { m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2); }); }; @@ -205,7 +205,7 @@ NewFontDialog::NewFontDialog(GUI::Window* parent_window) preview_editor.set_preview_size(m_glyph_width_spinbox->value(), value); m_mean_line_spinbox->set_max(max(value - 2, 0)); m_baseline_spinbox->set_max(max(value - 2, 0)); - deferred_invoke([&] { + deferred_invoke([&](auto&) { m_glyph_editor_container->set_fixed_height(1 + preview_editor.height() + preview_editor.frame_thickness() * 2); }); }; -- cgit v1.2.3