Skip to content

Commit

Permalink
[glass] Don't limit window name+label to 128 chars (wpilibsuite#6447)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterJohnson authored and DeltaDizzy committed Mar 26, 2024
1 parent 97df6f2 commit 417788a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions glass/src/lib/native/cpp/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

#include "glass/Window.h"

#include <string>

#include <fmt/format.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <wpi/StringExtras.h>

#include "glass/Context.h"
#include "glass/Storage.h"
Expand Down Expand Up @@ -55,15 +57,14 @@ void Window::Display() {
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, m_padding);
}

char label[128];
std::string label;
if (m_name.empty()) {
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_defaultName,
m_id);
label = fmt::format("{}###{}", m_defaultName, m_id);
} else {
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_name, m_id);
label = fmt::format("{}###{}", m_name, m_id);
}

if (Begin(label, &m_visible, m_flags)) {
if (Begin(label.c_str(), &m_visible, m_flags)) {
if (m_renamePopupEnabled || m_view->HasSettings()) {
bool isClicked = (ImGui::IsMouseReleased(ImGuiMouseButton_Right) &&
ImGui::IsItemHovered());
Expand Down

0 comments on commit 417788a

Please sign in to comment.