Shortcut ctrl+c hangs my programm (editBox)

Started by billarhos, 09 March 2016, 15:28:54

billarhos

Hi

When press ctrl+c, in all cases (empty edibox, edibox with text, editbox with text selected) i got exception error.
Happens in debug and release.
Are shortcuts supported by editbox?

Using Visual studio 2013
thanks

texus

Could you perhaps send me the callstack when it crashes in debug mode?

QuoteAre shortcuts supported by editbox?
They are supposed to work.

texus

I can't reproduce it on my windows machine but I'm having other issues here that might influence the result. Just to be certain, you can select text by dragging with your mouse right?

On my linux on which I develop I can't reproduce it either, but that is probably because the issue is going to be in the windows specific code that accesses the system clipboard.

So hopefully with a callstack I will be able to determine what is going wrong and fix it, because I may not be able to debug it myself soon.

billarhos

Yes, i can select the text in the text box.
How can i help u more?

texus

QuoteHow can i help u more?
When it crashes you should be able to break and see where it crashes exactly. If you are in debug mode you must also be linking to the debug tgui library so there will be a very detailed trace of where it crashes. If you can send the contents (or a screenshot after making sure the whole lines are visible) of the call stack window in VS then I should have some information to start looking at.

billarhos


it crashes here
-->strcpy_s(pchData, sizeof(pchData), m_contents.toAnsiString().c_str());

billarhos

Use memcpy instead:
memcpy(pchData, LPCTSTR(m_contents.toAnsiString().c_str()), m_contents.getSize()); it works


Also a GlobalFree i beleive is missing from get(). Not sure...

texus

Thanks for finding the issue. I have no idea why strcpy_s would suddenly fail though, that code worked fine before.
Could you test one last thing? Try replacing it with this:
Code (cpp) Select
memcpy(pchData, m_contents.toAnsiString().c_str(), m_contents.getSize() + 1);

It is stupid that I handled this line differently in v0.6 and v0.7. In TGUI 0.6 I replaced strcpy with memcpy while for TGUI 0.7 I decided on using strcpy_s.

QuoteAlso a GlobalFree i beleive is missing from get(). Not sure...
I just looked it up again and the MSDN example on clipboards doesn't has a free so I guess it is not needed since there is no alloc call like in the set function.

billarhos


texus

Great, thanks. I've updated TGUI now to use memcpy.

If only the Visual Studio compiler would be better, I would be able to run my tests on windows and try to prevent issues like this.