simongeilfus / Cinder-ImGui

Dear ImGui Renderer/Wrapper for Cinder
153 stars 96 forks source link

latest imgui breaks the CinderBlock (SetClipboardTextFn, GetClipboardTextFn) #44

Closed q-depot closed 7 years ago

q-depot commented 7 years ago

Hi Simon,

I've pulled the latest imgui subrepo and it doesn't compile anymore, I think the ImGui syntax for SetClipboardTextFn and GetClipboardTextFn have changed adding an extra "void* user_data" argument.

I've updated the Cinder-ImGui code and it does compile, but I'm not sure how the clipboard works so I didn't submit a pull request or tested anything, you might want to double check it.

CinderImGui.cpp #1004


#ifndef CINDER_LINUX
    // clipboard callbacks
    io.SetClipboardTextFn = []( void* user_data, const char* text ){
        const char* text_end = text + strlen(text);
        char* buf = (char*)malloc(text_end - text + 1);
        memcpy(buf, text, text_end-text);
        buf[text_end-text] = '\0';
        Clipboard::setString( buf );
        free(buf);
    };
    io.GetClipboardTextFn = []( void* user_data ){
        string str = Clipboard::getString();
        static vector<char> strCopy;
        strCopy = vector<char>(str.begin(), str.end());
        strCopy.push_back('\0');
        return (const char *) &strCopy[0];
    };
#endif```
origamidance commented 7 years ago

same problem here

q-depot commented 7 years ago

the code above should fix it

simongeilfus commented 7 years ago

Thanks Andrea, I'll look into that asap!

q-depot commented 7 years ago

you can find a commit here to fix the issue https://github.com/q-depot/Cinder-ImGui/commit/ef9772fd416be4472947e6799dab8caaa6fb6bf1