mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
AK: Simplify constructors and conversions from nullptr_t
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
This commit is contained in:
parent
9dc44bf8c4
commit
e6f907a155
105 changed files with 300 additions and 244 deletions
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibGUI/AboutDialog.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
|
@ -39,7 +40,7 @@ namespace CommonActions {
|
|||
|
||||
NonnullRefPtr<Action> make_about_action(const String& app_name, const Icon& app_icon, Window* parent)
|
||||
{
|
||||
WeakPtr<Window> weak_parent = parent ? parent->make_weak_ptr<Window>() : nullptr;
|
||||
auto weak_parent = AK::try_make_weak_ptr<Window>(parent);
|
||||
return Action::create(String::formatted("About {}", app_name), app_icon.bitmap_for_size(16), [=](auto&) {
|
||||
AboutDialog::show(app_name, app_icon.bitmap_for_size(32), weak_parent.ptr());
|
||||
});
|
||||
|
@ -288,7 +289,7 @@ void Action::set_checked(bool checked)
|
|||
|
||||
void Action::set_group(Badge<ActionGroup>, ActionGroup* group)
|
||||
{
|
||||
m_action_group = group ? group->make_weak_ptr() : nullptr;
|
||||
m_action_group = AK::try_make_weak_ptr(group);
|
||||
}
|
||||
|
||||
void Action::set_icon(const Gfx::Bitmap* icon)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue