Fix crash

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-10 17:25:42 +03:00
parent c4e13985ed
commit d5af4c9baf
4 changed files with 35 additions and 2 deletions

View File

@@ -146,6 +146,10 @@ App::~App()
if (m_sfd != -1)
close(m_sfd);
for (auto &[_, tex] : m_textures) {
UnloadTexture(tex);
}
destroy_layer_surface();
if (m_gl.edpy != EGL_NO_DISPLAY) {
@@ -597,7 +601,12 @@ auto App::init_wayland() -> void
if (!ctx->data.empty())
ctx->app->m_clipboard_cache
= std::move(ctx->data);
wl_data_offer_destroy(ctx->offer);
if (ctx->offer
== ctx->app->m_wayland.curr_offer) {
wl_data_offer_destroy(ctx->offer);
ctx->app->m_wayland.curr_offer
= nullptr;
}
delete ctx;
return G_SOURCE_REMOVE;
},

View File

@@ -1,5 +1,7 @@
#pragma once
#include <cassert>
#include <filesystem>
#include <string>
#include <unordered_set>
#include <vector>
@@ -196,6 +198,23 @@ private:
bool surrounding_dirty { false };
} m_ime;
// NOTE: Canonicalize first!
std::unordered_map<std::filesystem::path, Texture2D> m_textures;
auto get_texture(std::filesystem::path const &path) -> Texture2D const &
{
if (m_textures.contains(path)) {
return m_textures[path];
}
auto fname = path.c_str();
assert(fname);
TraceLog(LOG_INFO, std::format("loading texture at {}", fname).c_str());
auto const tex = LoadTexture(fname);
assert(IsTextureValid(tex));
m_textures[path] = tex;
return m_textures[path];
}
enum_array<Theme, ColorScheme> m_themes { make_default_themes() };
Theme m_active_theme { Theme::Light };

View File

@@ -8,6 +8,9 @@
#include <rlgl.h>
#include <xkbcommon/xkbcommon.h>
#include <filesystem>
#include <optional>
auto App::tick() -> void
{
static std::pmr::string text_input_data {};
@@ -62,6 +65,8 @@ auto App::tick() -> void
update_text_input_state(text_input_data, 1, input_rect);
}
// DrawTexture(get_texture(*icon_lookup("folder", 32)), 50, 50, WHITE);
EndDrawing();
eglSwapBuffers(m_gl.edpy, m_gl.esurf);