fix: brief freezes after file dialogs / fontconfig methods are used

This commit is contained in:
2026-01-12 23:52:33 +03:00
parent d852d58948
commit 2b1c6d59c4
6 changed files with 46 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev> # Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync pkgname=clrsync
pkgver=1.0.2 pkgver=1.0.4
pkgrel=1 pkgrel=1
pkgdesc="Color scheme manager" pkgdesc="Color scheme manager"
arch=('x86_64') arch=('x86_64')

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(clrsync VERSION 1.0.2 LANGUAGES CXX) project(clrsync VERSION 1.0.4 LANGUAGES CXX)
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@@ -1 +1 @@
1.0.2 1.0.4

View File

@@ -6,7 +6,7 @@
namespace clrsync::core namespace clrsync::core
{ {
const std::string GIT_SEMVER = "1.0.2+git.g41939f4"; const std::string GIT_SEMVER = "1.0.3+git.gd852d58";
const std::string version_string(); const std::string version_string();
} // namespace clrsync::core } // namespace clrsync::core

View File

@@ -3,6 +3,7 @@
#include "gui/platform/file_browser.hpp" #include "gui/platform/file_browser.hpp"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <filesystem> #include <filesystem>
#include <GLFW/glfw3.h>
namespace file_dialogs namespace file_dialogs
{ {
@@ -38,7 +39,16 @@ std::string open_file_dialog(const std::string &title, const std::string &initia
} }
std::string result; std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{ {
char *filename = gtk_file_chooser_get_filename(chooser); char *filename = gtk_file_chooser_get_filename(chooser);
if (filename) if (filename)
@@ -79,7 +89,16 @@ std::string save_file_dialog(const std::string &title, const std::string &initia
} }
std::string result; std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{ {
char *filename = gtk_file_chooser_get_filename(chooser); char *filename = gtk_file_chooser_get_filename(chooser);
if (filename) if (filename)
@@ -113,7 +132,16 @@ std::string select_folder_dialog(const std::string &title, const std::string &in
} }
std::string result; std::string result;
if (gtk_native_dialog_run(GTK_NATIVE_DIALOG(native)) == GTK_RESPONSE_ACCEPT)
gint response = gtk_native_dialog_run(GTK_NATIVE_DIALOG(native));
while (gtk_events_pending())
{
gtk_main_iteration();
glfwPollEvents();
}
if (response == GTK_RESPONSE_ACCEPT)
{ {
char *filename = gtk_file_chooser_get_filename(chooser); char *filename = gtk_file_chooser_get_filename(chooser);
if (filename) if (filename)

View File

@@ -6,9 +6,12 @@
#include <algorithm> #include <algorithm>
#include <fontconfig/fontconfig.h> #include <fontconfig/fontconfig.h>
#include <imgui.h> #include <imgui.h>
#include <GLFW/glfw3.h>
std::string font_loader::find_font_linux(const char *font_name) std::string font_loader::find_font_linux(const char *font_name)
{ {
glfwPollEvents();
FcInit(); FcInit();
FcPattern *pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_name)); FcPattern *pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_name));
@@ -65,6 +68,8 @@ std::vector<std::string> font_loader::get_system_fonts()
{ {
std::vector<std::string> fonts; std::vector<std::string> fonts;
glfwPollEvents();
FcInit(); FcInit();
FcPattern *pattern = FcPatternCreate(); FcPattern *pattern = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, nullptr); FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, nullptr);
@@ -74,6 +79,12 @@ std::vector<std::string> font_loader::get_system_fonts()
{ {
for (int i = 0; i < fs->nfont; i++) for (int i = 0; i < fs->nfont; i++)
{ {
// TODO: should change this to something sane
if (i % 100 == 0)
{
glfwPollEvents();
}
FcChar8 *family = nullptr; FcChar8 *family = nullptr;
if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch) if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch)
{ {