ladybird/Userland/Libraries/LibGUI/Process.cpp
Ben Wiederhake 6fd478b6ce Everywhere: Remove unused includes of AK/Format.h
These instances were detected by searching for files that include
AK/Format.h, but don't match the regex:

\\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu
ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo
rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out
|outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr
asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf
ormat|vout|warn|warnln|warnln_if)\\b

(Without the linebreaks.)

This regex is pessimistic, so there might be more files that don't
actually use any formatting functions.

Observe that this revealed that Userland/Libraries/LibC/signal.cpp is
missing an include.

In theory, one might use LibCPP to detect things like this
automatically, but let's do this one step after another.
2023-01-02 20:27:20 -05:00

36 lines
1.1 KiB
C++

/*
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/StringView.h>
#include <LibGUI/MessageBox.h>
#include <LibGUI/Process.h>
template<typename StringType>
void spawn_or_show_error(GUI::Window* parent_window, StringView path, Span<StringType const> arguments)
{
auto spawn_result = Core::Process::spawn(path, arguments);
if (spawn_result.is_error())
GUI::MessageBox::show_error(parent_window, DeprecatedString::formatted("Failed to spawn {}: {}", path, spawn_result.error()));
}
namespace GUI {
void Process::spawn_or_show_error(Window* parent_window, StringView path, Span<DeprecatedString const> arguments)
{
::spawn_or_show_error<DeprecatedString>(parent_window, path, arguments);
}
void Process::spawn_or_show_error(Window* parent_window, StringView path, Span<StringView const> arguments)
{
::spawn_or_show_error<StringView>(parent_window, path, arguments);
}
void Process::spawn_or_show_error(Window* parent_window, StringView path, Span<char const* const> arguments)
{
::spawn_or_show_error<char const*>(parent_window, path, arguments);
}
}