mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-14 01:41:46 +08:00
Limit count of thread generating preview image of font (Limitation of opened files on Linux)
This commit is contained in:
parent
24b71ada5e
commit
78f002cee8
@ -1307,7 +1307,10 @@ void GLGizmoEmboss::draw_font_list()
|
|||||||
size_t index = &face_name - &m_face_names.names.front();
|
size_t index = &face_name - &m_face_names.names.front();
|
||||||
ImGui::PushID(index);
|
ImGui::PushID(index);
|
||||||
bool is_selected = (actual_face_name == face_name);
|
bool is_selected = (actual_face_name == face_name);
|
||||||
if (ImGui::Selectable(m_face_names.names_truncated[index].c_str(), is_selected)) {
|
ImVec2 selectable_size(0, m_gui_cfg->face_name_size.y());
|
||||||
|
ImGuiSelectableFlags flags = 0;
|
||||||
|
if (ImGui::Selectable(m_face_names.names_truncated[index].c_str(),
|
||||||
|
is_selected, flags, selectable_size)) {
|
||||||
if (!select_facename(face_name)) {
|
if (!select_facename(face_name)) {
|
||||||
del_facename = face_name;
|
del_facename = face_name;
|
||||||
wxMessageBox(GUI::format(
|
wxMessageBox(GUI::format(
|
||||||
@ -1317,8 +1320,15 @@ void GLGizmoEmboss::draw_font_list()
|
|||||||
if (ImGui::IsItemHovered())
|
if (ImGui::IsItemHovered())
|
||||||
ImGui::SetTooltip("%s", face_name.ToUTF8().data());
|
ImGui::SetTooltip("%s", face_name.ToUTF8().data());
|
||||||
if (is_selected) ImGui::SetItemDefaultFocus();
|
if (is_selected) ImGui::SetItemDefaultFocus();
|
||||||
if (!m_face_names.exist_textures[index] &&
|
if (m_face_names.exist_textures[index]) {
|
||||||
ImGui::IsItemVisible()) {
|
ImGui::SameLine(m_gui_cfg->face_name_max_width);
|
||||||
|
ImVec2 size(m_gui_cfg->face_name_size.x(),
|
||||||
|
m_gui_cfg->face_name_size.y()),
|
||||||
|
uv0(0.f, index / (float) m_face_names.names.size()),
|
||||||
|
uv1(1.f, (index + 1) / (float) m_face_names.names.size());
|
||||||
|
ImGui::Image(tex_id, size, uv0, uv1);
|
||||||
|
} else if (ImGui::IsItemVisible() && m_count_opened_font_files < 10) {
|
||||||
|
++m_count_opened_font_files;
|
||||||
m_face_names.exist_textures[index] = true;
|
m_face_names.exist_textures[index] = true;
|
||||||
std::string text = m_text.empty() ? "AaBbCc" : m_text;
|
std::string text = m_text.empty() ? "AaBbCc" : m_text;
|
||||||
|
|
||||||
@ -1337,17 +1347,13 @@ void GLGizmoEmboss::draw_font_list()
|
|||||||
gray_level,
|
gray_level,
|
||||||
format,
|
format,
|
||||||
type,
|
type,
|
||||||
level};
|
level,
|
||||||
|
&m_count_opened_font_files };
|
||||||
auto job = std::make_unique<CreateFontImageJob>(std::move(data));
|
auto job = std::make_unique<CreateFontImageJob>(std::move(data));
|
||||||
auto& worker = wxGetApp().plater()->get_ui_job_worker();
|
auto& worker = wxGetApp().plater()->get_ui_job_worker();
|
||||||
queue_job(worker, std::move(job));
|
queue_job(worker, std::move(job));
|
||||||
}
|
}
|
||||||
ImGui::SameLine(m_gui_cfg->face_name_max_width);
|
|
||||||
ImVec2 size(m_gui_cfg->face_name_size.x(),
|
|
||||||
m_gui_cfg->face_name_size.y()),
|
|
||||||
uv0(0.f, index / (float) m_face_names.names.size()),
|
|
||||||
uv1(1.f, (index + 1) / (float) m_face_names.names.size());
|
|
||||||
ImGui::Image(tex_id, size, uv0, uv1);
|
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
#ifdef SHOW_FONT_COUNT
|
#ifdef SHOW_FONT_COUNT
|
||||||
|
@ -246,8 +246,11 @@ private:
|
|||||||
// cancel for previous update of volume to cancel finalize part
|
// cancel for previous update of volume to cancel finalize part
|
||||||
std::shared_ptr<std::atomic<bool>> m_update_job_cancel;
|
std::shared_ptr<std::atomic<bool>> m_update_job_cancel;
|
||||||
|
|
||||||
// cancel for rendering font name
|
// cancel for rendering font name after close comboBox
|
||||||
bool m_allow_update_rendered_font;
|
bool m_allow_update_rendered_font;
|
||||||
|
// protection for open too much font files together
|
||||||
|
// Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /usr/share/icons/Yaru/48x48/status/image-missing.png: Error opening file /usr/share/icons/Yaru/48x48/status/image-missing.png: Too many open files (g-io-error-quark, 31)
|
||||||
|
unsigned int m_count_opened_font_files = 0;
|
||||||
|
|
||||||
// Rotation gizmo
|
// Rotation gizmo
|
||||||
GLGizmoRotate m_rotate_gizmo;
|
GLGizmoRotate m_rotate_gizmo;
|
||||||
|
@ -94,6 +94,8 @@ void CreateFontImageJob::process(Ctl &ctl)
|
|||||||
|
|
||||||
void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &)
|
void CreateFontImageJob::finalize(bool canceled, std::exception_ptr &)
|
||||||
{
|
{
|
||||||
|
if (m_input.count_opened_font_files)
|
||||||
|
--(*m_input.count_opened_font_files);
|
||||||
if (canceled) return;
|
if (canceled) return;
|
||||||
if (! (* m_input.allow_update)) return;
|
if (! (* m_input.allow_update)) return;
|
||||||
|
|
||||||
|
@ -39,6 +39,10 @@ struct FontImageData
|
|||||||
// texture meta data
|
// texture meta data
|
||||||
GLenum format = GL_ALPHA, type = GL_UNSIGNED_BYTE;
|
GLenum format = GL_ALPHA, type = GL_UNSIGNED_BYTE;
|
||||||
GLint level = 0;
|
GLint level = 0;
|
||||||
|
|
||||||
|
// prevent opening too much files
|
||||||
|
// it is decreased in finalize phase
|
||||||
|
unsigned int *count_opened_font_files = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user