Shortcut ctrl+c hangs my programm (editBox)
« on: 09 March 2016, 15:28:54 »
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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #1 on: 09 March 2016, 15:32:11 »
Could you perhaps send me the callstack when it crashes in debug mode?

Quote
Are shortcuts supported by editbox?
They are supposed to work.

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #2 on: 09 March 2016, 17:21:04 »
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.

Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #3 on: 09 March 2016, 18:32:08 »
Yes, i can select the text in the text box.
How can i help u more?

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #4 on: 09 March 2016, 18:37:07 »
Quote
How 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.

Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #5 on: 09 March 2016, 18:54:54 »

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

Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #6 on: 09 March 2016, 19:02:34 »
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

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #7 on: 09 March 2016, 19:27:15 »
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:
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.

Quote
Also 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.

Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #8 on: 09 March 2016, 19:55:37 »
Yeap, it is working..
Cheers

*

texus

  • *****
  • 1143
    • View Profile
    • Texus's Blog
Re: Shortcut ctrl+c hangs my programm (editBox)
« Reply #9 on: 09 March 2016, 20:06:02 »
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.