Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emscripten + Saving editor state #177

Open
pavanakumar opened this issue Jan 29, 2023 · 0 comments
Open

emscripten + Saving editor state #177

pavanakumar opened this issue Jan 29, 2023 · 0 comments

Comments

@pavanakumar
Copy link

Imnodes saves the editor state to the ini file in lines 3232-3246 of file imnodes.cpp,

void SaveEditorStateToIniFile(const ImNodesEditorContext* const editor, const char* const file_name)
{
    size_t      data_size = 0u;
    const char* data = SaveEditorStateToIniString(editor, &data_size);
    FILE*       file = ImFileOpen(file_name, "wt");
    if (!file)
    {
        return;
    }

    fwrite(data, sizeof(char), data_size, file);
    fclose(file);
}

Just by protecting this using the __EMSCRIPTEN__ macro helps,

void SaveEditorStateToIniFile(const ImNodesEditorContext* const editor, const char* const file_name)
{
#ifndef __EMSCRIPTEN__
    size_t      data_size = 0u;
    const char* data = SaveEditorStateToIniString(editor, &data_size);
    FILE*       file = ImFileOpen(file_name, "wt");
    if (!file)
    {
        return;
    }

    fwrite(data, sizeof(char), data_size, file);
    fclose(file);
#endif
}

The browser does not allow access to the filesystem unless you are running this via Node. Just wanted to put this issue here if someone faced similar issue and wants a work around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant