crash issues + fixes
This commit is contained in:
@@ -714,12 +714,6 @@ namespace anm2ed::imgui
|
|||||||
reference_clear_for(document);
|
reference_clear_for(document);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto reference_set_item = [&](int type, int id)
|
|
||||||
{
|
|
||||||
group_selection_reset();
|
|
||||||
reference_set_item_for(document, type, id);
|
|
||||||
};
|
|
||||||
|
|
||||||
auto reference_set_timeline_item = [&](int type, int id)
|
auto reference_set_timeline_item = [&](int type, int id)
|
||||||
{
|
{
|
||||||
group_selection_reset();
|
group_selection_reset();
|
||||||
@@ -2547,11 +2541,6 @@ namespace anm2ed::imgui
|
|||||||
{
|
{
|
||||||
float frameTime{};
|
float frameTime{};
|
||||||
|
|
||||||
if (!isFrameBoxPending && !isFrameBoxSelecting && !frameMoveDrag.isActive && ImGui::IsWindowHovered() &&
|
|
||||||
(ImGui::IsMouseReleased(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Right)) &&
|
|
||||||
!ImGui::IsAnyItemHovered())
|
|
||||||
reference_set_item(type, id);
|
|
||||||
|
|
||||||
for (int i = frameMin; i < frameMax; i++)
|
for (int i = frameMin; i < frameMax; i++)
|
||||||
{
|
{
|
||||||
auto frameScreenPos = ImVec2(cursorScreenPos.x + frameSize.x * (float)i, cursorScreenPos.y);
|
auto frameScreenPos = ImVec2(cursorScreenPos.x + frameSize.x * (float)i, cursorScreenPos.y);
|
||||||
@@ -2842,6 +2831,11 @@ namespace anm2ed::imgui
|
|||||||
ImGui::GetColorU32(ImGuiCol_DragDropTarget), FRAME_ROUNDING, 0,
|
ImGui::GetColorU32(ImGuiCol_DragDropTarget), FRAME_ROUNDING, 0,
|
||||||
ImGui::GetStyle().DragDropTargetBorderSize * 1.5f);
|
ImGui::GetStyle().DragDropTargetBorderSize * 1.5f);
|
||||||
|
|
||||||
|
if (!isFrameBoxSelecting && !frameMoveDrag.isActive && !isDraggedFrameActive && ImGui::IsWindowHovered() &&
|
||||||
|
(ImGui::IsMouseReleased(ImGuiMouseButton_Left) || ImGui::IsMouseReleased(ImGuiMouseButton_Right)) &&
|
||||||
|
!ImGui::IsAnyItemHovered())
|
||||||
|
row_selection_set(row);
|
||||||
|
|
||||||
if (isFrameSelectionLocked)
|
if (isFrameSelectionLocked)
|
||||||
{
|
{
|
||||||
frames.selection.clear();
|
frames.selection.clear();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "sdl.hpp"
|
#include "sdl.hpp"
|
||||||
|
#include "texture.hpp"
|
||||||
|
|
||||||
#include "util/imgui/imgui.hpp"
|
#include "util/imgui/imgui.hpp"
|
||||||
|
|
||||||
@@ -317,6 +318,7 @@ namespace anm2ed
|
|||||||
if (ImGui::GetCurrentContext())
|
if (ImGui::GetCurrentContext())
|
||||||
{
|
{
|
||||||
settings.save(settings_path(), ImGui::SaveIniSettingsToMemory(nullptr));
|
settings.save(settings_path(), ImGui::SaveIniSettingsToMemory(nullptr));
|
||||||
|
resource::Texture::garbage_collect();
|
||||||
|
|
||||||
ImGui_ImplSDL3_Shutdown();
|
ImGui_ImplSDL3_Shutdown();
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
|||||||
@@ -31,12 +31,24 @@ using namespace anm2ed::util::math;
|
|||||||
using namespace anm2ed::util;
|
using namespace anm2ed::util;
|
||||||
using namespace glm;
|
using namespace glm;
|
||||||
|
|
||||||
|
namespace anm2ed::resource::texture
|
||||||
|
{
|
||||||
|
std::vector<GLuint> retiredTextureIds{};
|
||||||
|
}
|
||||||
|
|
||||||
namespace anm2ed::resource
|
namespace anm2ed::resource
|
||||||
{
|
{
|
||||||
bool Texture::is_valid() const { return id != 0; }
|
bool Texture::is_valid() const { return id != 0; }
|
||||||
|
|
||||||
size_t Texture::pixel_size_get() const { return size.x * size.y * CHANNELS; }
|
size_t Texture::pixel_size_get() const { return size.x * size.y * CHANNELS; }
|
||||||
|
|
||||||
|
void Texture::release()
|
||||||
|
{
|
||||||
|
if (!is_valid()) return;
|
||||||
|
texture::retiredTextureIds.push_back(id);
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Texture::upload(const uint8_t* data)
|
void Texture::upload(const uint8_t* data)
|
||||||
{
|
{
|
||||||
if (!data || size.x <= 0 || size.y <= 0) return;
|
if (!data || size.x <= 0 || size.y <= 0) return;
|
||||||
@@ -59,10 +71,7 @@ namespace anm2ed::resource
|
|||||||
|
|
||||||
Texture::Texture() = default;
|
Texture::Texture() = default;
|
||||||
|
|
||||||
Texture::~Texture()
|
Texture::~Texture() { release(); }
|
||||||
{
|
|
||||||
if (is_valid()) glDeleteTextures(1, &id);
|
|
||||||
}
|
|
||||||
|
|
||||||
Texture::Texture(const Texture& other) { *this = other; }
|
Texture::Texture(const Texture& other) { *this = other; }
|
||||||
|
|
||||||
@@ -72,7 +81,7 @@ namespace anm2ed::resource
|
|||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
if (is_valid()) glDeleteTextures(1, &id);
|
release();
|
||||||
size = other.size;
|
size = other.size;
|
||||||
filter = other.filter;
|
filter = other.filter;
|
||||||
channels = other.channels;
|
channels = other.channels;
|
||||||
@@ -86,7 +95,7 @@ namespace anm2ed::resource
|
|||||||
{
|
{
|
||||||
if (this != &other)
|
if (this != &other)
|
||||||
{
|
{
|
||||||
if (is_valid()) glDeleteTextures(1, &id);
|
release();
|
||||||
id = other.id;
|
id = other.id;
|
||||||
size = other.size;
|
size = other.size;
|
||||||
filter = other.filter;
|
filter = other.filter;
|
||||||
@@ -97,6 +106,13 @@ namespace anm2ed::resource
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Texture::garbage_collect()
|
||||||
|
{
|
||||||
|
if (texture::retiredTextureIds.empty()) return;
|
||||||
|
glDeleteTextures((GLsizei)texture::retiredTextureIds.size(), texture::retiredTextureIds.data());
|
||||||
|
texture::retiredTextureIds.clear();
|
||||||
|
}
|
||||||
|
|
||||||
Texture::Texture(const char* svgData, size_t svgDataLength, ivec2 svgSize)
|
Texture::Texture(const char* svgData, size_t svgDataLength, ivec2 svgSize)
|
||||||
{
|
{
|
||||||
if (!svgData) return;
|
if (!svgData) return;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace anm2ed::resource
|
|||||||
|
|
||||||
bool is_valid() const;
|
bool is_valid() const;
|
||||||
size_t pixel_size_get() const;
|
size_t pixel_size_get() const;
|
||||||
|
void release();
|
||||||
void upload();
|
void upload();
|
||||||
void upload(const uint8_t*);
|
void upload(const uint8_t*);
|
||||||
glm::vec4 pixel_read(glm::vec2) const;
|
glm::vec4 pixel_read(glm::vec2) const;
|
||||||
@@ -40,6 +41,7 @@ namespace anm2ed::resource
|
|||||||
Texture(const char*, size_t, glm::ivec2);
|
Texture(const char*, size_t, glm::ivec2);
|
||||||
Texture(const std::filesystem::path&);
|
Texture(const std::filesystem::path&);
|
||||||
bool write_png(const std::filesystem::path&);
|
bool write_png(const std::filesystem::path&);
|
||||||
|
static void garbage_collect();
|
||||||
static bool write_pixels_png(const std::filesystem::path&, glm::ivec2, const uint8_t*);
|
static bool write_pixels_png(const std::filesystem::path&, glm::ivec2, const uint8_t*);
|
||||||
static Texture merge_append(const Texture&, const Texture&, bool);
|
static Texture merge_append(const Texture&, const Texture&, bool);
|
||||||
void pixel_set(glm::ivec2, glm::vec4);
|
void pixel_set(glm::ivec2, glm::vec4);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
#include "path.hpp"
|
#include "path.hpp"
|
||||||
#include "strings.hpp"
|
#include "strings.hpp"
|
||||||
|
#include "texture.hpp"
|
||||||
#include "toast.hpp"
|
#include "toast.hpp"
|
||||||
#include "util/imgui/shortcut.hpp"
|
#include "util/imgui/shortcut.hpp"
|
||||||
|
|
||||||
@@ -207,6 +208,7 @@ namespace anm2ed
|
|||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
resource::Texture::garbage_collect();
|
||||||
SDL_GL_SetSwapInterval(settings.isVsync);
|
SDL_GL_SetSwapInterval(settings.isVsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user