Coder Social home page Coder Social logo

Comments (5)

PathogenDavid avatar PathogenDavid commented on May 30, 2024 1

The easiest route would be to save and restore the clipboard functions before/after the backend initialization. IE:

auto defaultSetClipboardTextFn = io.SetClipboardTextFn;
auto defaultGetClipboardTextFn = io.GetClipboardTextFn;
auto defaultClipboardUserData = io.ClipboardUserData;
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
io.SetClipboardTextFn = defaultSetClipboardTextFn;
io.GetClipboardTextFn = defaultGetClipboardTextFn;
io.ClipboardUserData = defaultClipboardUserData;

from imgui.

paul-akl avatar paul-akl commented on May 30, 2024 1

The easiest route would be to save and restore the clipboard functions before/after the backend initialization. IE:

auto defaultSetClipboardTextFn = io.SetClipboardTextFn;
auto defaultGetClipboardTextFn = io.GetClipboardTextFn;
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
io.SetClipboardTextFn = defaultSetClipboardTextFn;
io.GetClipboardTextFn = defaultGetClipboardTextFn;

That is actually a clever solution, how didn't I think of that. Thank you!

I'll keep the issue open for a bit, in case someone comments with a direct way to get the default clipboard implementation.

EDIT:
For this solution to work correctly, one needs to set the ClipboardUserData as well, since it is set to nullptr in the SDL2 implementation, thus ImGui throws an exception when reading the clipboard by trying to clear the nullptr.

Amended solution that works for me:

auto defaultSetClipboardTextFn = io.SetClipboardTextFn;
auto defaultGetClipboardTextFn = io.GetClipboardTextFn;
auto defaultClipboardUserData = io.ClipboardUserData;

ImGui_ImplSDL2_InitForOpenGL(window, gl_context);

io.SetClipboardTextFn = defaultSetClipboardTextFn;
io.GetClipboardTextFn = defaultGetClipboardTextFn;
io.ClipboardUserData = defaultClipboardUserData;

from imgui.

PathogenDavid avatar PathogenDavid commented on May 30, 2024 1

ClipboardUserData

Oops yeah, that's my bad. Sorry about that! 😅

from imgui.

ocornut avatar ocornut commented on May 30, 2024

Also make sure that what you perceive as hanging isn’t some kind of symbol loading performed by the debugger (in which case you may set it up to lazily load symbols on crash only).

from imgui.

paul-akl avatar paul-akl commented on May 30, 2024

Also make sure that what you perceive as hanging isn’t some kind of symbol loading performed by the debugger (in which case you may set it up to lazily load symbols on crash only).

Thanks for your input, ocornut!

It wasn't a debuggers fault, as the same hanging is happening when manually running the binary compiled in release mode. In addition, the freezing happens every time the clipboard is accessed, not just the first time after running the program.

Assuming there is no intended way to explicitly access the default clipboard implementation and there is a work-around that I'm happy with, I'll close the issue as resolved 👍

from imgui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.