gui: Fix layout file not being created for the first time on Windows

By ensuring imgui.ini exists.
Also enabled u_config_json_open_or_create_file for Windows as this OS has an
implementation of u_file_get_path_in_config_dir available now.
This commit is contained in:
Mateo de Mayo 2022-09-19 12:44:40 -03:00 committed by Moses Turner
parent bd265c611d
commit 3d366b9243
3 changed files with 13 additions and 1 deletions

View file

@ -44,7 +44,7 @@ static void
u_config_json_open_or_create_file(struct u_config_json *json, const char *filename)
{
json->file_loaded = false;
#if defined(XRT_OS_LINUX) && !defined(XRT_OS_ANDROID)
#if (defined(XRT_OS_LINUX) || defined(XRT_OS_WINDOWS)) && !defined(XRT_OS_ANDROID)
char tmp[1024];
ssize_t ret = u_file_get_path_in_config_dir(filename, tmp, sizeof(tmp));
if (ret <= 0) {

View file

@ -60,6 +60,12 @@ gui_sdl2_imgui_loop(struct sdl2_program *p)
assert(res > 0);
io->IniFilename = p->layout_file;
// Ensure imgui.ini file exists in config dir
FILE *imgui_ini = u_file_open_file_in_config_dir("imgui.ini", "a");
if (imgui_ini != NULL) {
fclose(imgui_ini);
}
// Setup Platform/Renderer bindings
igImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
igImGui_ImplOpenGL3_Init(NULL);

View file

@ -150,6 +150,12 @@ sdl2_loop(struct sdl2_program *p)
assert(res > 0);
io->IniFilename = p->layout_file;
// Ensure imgui.ini file exists in config dir
FILE *imgui_ini = u_file_open_file_in_config_dir("imgui.ini", "a");
if (imgui_ini != NULL) {
fclose(imgui_ini);
}
// Setup Platform/Renderer bindings
igImGui_ImplSDL2_InitForOpenGL(p->win, p->ctx);
igImGui_ImplOpenGL3_Init(NULL);