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

View file

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

View file

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