GUI: delayed layout loading

issue #1629
This commit is contained in:
tildearrow 2024-01-26 02:44:47 -05:00
parent ba8cd2f672
commit c55cc8b2ea
3 changed files with 21 additions and 5 deletions

View file

@ -4001,12 +4001,24 @@ bool FurnaceGUI::loop() {
layoutTimeBegin=SDL_GetPerformanceCounter();
if (pendingLayoutImport!=NULL) {
ImGui::LoadIniSettingsFromMemory((const char*)pendingLayoutImport,pendingLayoutImportLen);
}
if (!rend->newFrame()) {
fontsFailed=true;
}
ImGui_ImplSDL2_NewFrame(sdlWin);
ImGui::NewFrame();
if (pendingLayoutImport!=NULL) {
WAKE_UP;
ImGui::Render();
delete[] pendingLayoutImport;
pendingLayoutImport=NULL;
continue;
}
// one second counter
secondTimer+=ImGui::GetIO().DeltaTime;
if (secondTimer>=1.0f) secondTimer=fmod(secondTimer,1.0f);
@ -7263,6 +7275,8 @@ FurnaceGUI::FurnaceGUI():
headFont(NULL),
fontRange(NULL),
prevInsData(NULL),
pendingLayoutImport(NULL),
pendingLayoutImportLen(0),
curIns(0),
curWave(0),
curSample(0),

View file

@ -1976,6 +1976,9 @@ class FurnaceGUI {
DivInstrument* prevInsData;
unsigned char* pendingLayoutImport;
size_t pendingLayoutImportLen;
int curIns, curWave, curSample, curOctave, curOrder, playOrder, prevIns, oldRow, editStep, exportLoops, soloChan, orderEditMode, orderCursor;
int loopOrder, loopRow, loopEnd, isClipping, newSongCategory, latchTarget;
int wheelX, wheelY, dragSourceX, dragSourceXFine, dragSourceY, dragDestinationX, dragDestinationXFine, dragDestinationY, oldBeat, oldBar;

View file

@ -4760,18 +4760,17 @@ bool FurnaceGUI::importLayout(String path) {
fclose(f);
return false;
}
unsigned char* file=new unsigned char[len];
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
pendingLayoutImport=new unsigned char[len];
if (fread(pendingLayoutImport,1,(size_t)len,f)!=(size_t)len) {
perror("read error");
lastError=fmt::sprintf("on read: %s",strerror(errno));
fclose(f);
delete[] file;
delete[] pendingLayoutImport;
return false;
}
fclose(f);
ImGui::LoadIniSettingsFromMemory((const char*)file,len);
delete[] file;
pendingLayoutImportLen=len;
return true;
}