Skip to content

Commit

Permalink
Replace std::snprintf() with fmt::format in ui::Alert
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Nov 7, 2024
1 parent 1e5e065 commit 69dd28c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ui/alert.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
Expand Down Expand Up @@ -36,6 +36,7 @@
#include "ui/alert.h"

#include "base/string.h"
#include "fmt/format.h"
#include "ui/box.h"
#include "ui/button.h"
#include "ui/grid.h"
Expand All @@ -46,7 +47,7 @@
#include "ui/theme.h"

#include <algorithm>
#include <cstdio>
#include <string>

namespace ui {

Expand Down Expand Up @@ -120,9 +121,7 @@ void Alert::addButton(const std::string& text)
button->setMinSize(gfx::Size(60*guiscale(), 0));
m_buttons.push_back(button);

char id[256];
std::snprintf(id, sizeof(id), "button-%lu", m_buttons.size());
button->setId(id);
button->setId(fmt::format("button-{}", m_buttons.size()).c_str());
button->Click.connect([this, button]{ closeWindow(button); });

m_buttonsPlaceholder->addChild(button);
Expand Down

0 comments on commit 69dd28c

Please sign in to comment.