[GH-ISSUE #69] Bug in drag and drop #38

Closed
opened 2026-05-05 03:35:38 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @kov-serg on GitHub (Apr 8, 2022).
Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/69

https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/Core/Defs.h#L157

typedef uint32             wchar;

https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/CtrlCore/CtrlClip.cpp#L118

String Unicode__(const WString& w)
{
	return String((const char *)~w, 2 * w.GetLength());
}

wchar is 4 bytes long so string will hold only one first characted.

How to reproduce. Create textedit type some text, select several letters and move it with mouse. It moves only first letter, rest will disappear.

ps:
https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/plugin/lz4/lib/lz4.c#L1348

static size_t LZ4_stream_t_alignment(void)
{
    struct { char c; LZ4_stream_t t; } t_a;
    return sizeof(t_a) - sizeof(t_a.t);
}

should be replaced with

static size_t LZ4_stream_t_alignment(void)
{
    struct { char c; int* t; } t_a;
    return sizeof(t_a) - sizeof(t_a.t);
}

in order to work with gcc, or it fall's on aligment check nearby an cause segav

Originally created by @kov-serg on GitHub (Apr 8, 2022). Original GitHub issue: https://github.com/ultimatepp/ultimatepp/issues/69 https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/Core/Defs.h#L157 ``` typedef uint32 wchar; ``` https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/CtrlCore/CtrlClip.cpp#L118 ``` String Unicode__(const WString& w) { return String((const char *)~w, 2 * w.GetLength()); } ``` wchar is 4 bytes long so string will hold only one first characted. How to reproduce. Create textedit type some text, select several letters and move it with mouse. It moves only first letter, rest will disappear. ps: https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/plugin/lz4/lib/lz4.c#L1348 ``` static size_t LZ4_stream_t_alignment(void) { struct { char c; LZ4_stream_t t; } t_a; return sizeof(t_a) - sizeof(t_a.t); } ``` should be replaced with ``` static size_t LZ4_stream_t_alignment(void) { struct { char c; int* t; } t_a; return sizeof(t_a) - sizeof(t_a.t); } ``` in order to work with gcc, or it fall's on aligment check [nearby](https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/plugin/lz4/lib/lz4.c#L1361) an cause segav
Author
Owner

@mirek-fidler commented on GitHub (Apr 11, 2022):

Should be now fixed (by removing Unicode__ functions completely). Thanks
for spotting this.

pá 8. 4. 2022 v 23:07 odesílatel kov-serg @.***> napsal:

https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/Core/Defs.h#L157
typedef uint32 wchar;

https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/CtrlCore/CtrlClip.cpp#L118
String Unicode__(const WString& w)
{
return String((const char *)~w, 2 * w.GetLength());
}


Reply to this email directly, view it on GitHub
https://github.com/ultimatepp/ultimatepp/issues/69, or unsubscribe
https://github.com/notifications/unsubscribe-auth/AARH235LHWGSNOUJKU2TXF3VECNZ5ANCNFSM5S5UQZEA
.
You are receiving this because you are subscribed to this thread.Message
ID: @.***>

<!-- gh-comment-id:1094932501 --> @mirek-fidler commented on GitHub (Apr 11, 2022): Should be now fixed (by removing Unicode__ functions completely). Thanks for spotting this. pá 8. 4. 2022 v 23:07 odesílatel kov-serg ***@***.***> napsal: > > https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/Core/Defs.h#L157 > typedef uint32 wchar; > > > https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/CtrlCore/CtrlClip.cpp#L118 > String Unicode__(const WString& w) > { > return String((const char *)~w, 2 * w.GetLength()); > } > > — > Reply to this email directly, view it on GitHub > <https://github.com/ultimatepp/ultimatepp/issues/69>, or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AARH235LHWGSNOUJKU2TXF3VECNZ5ANCNFSM5S5UQZEA> > . > You are receiving this because you are subscribed to this thread.Message > ID: ***@***.***> >
Author
Owner

@kov-serg commented on GitHub (Apr 12, 2022):

Did you check result?

pic-02
pic-03

From wordpad text inserted without problem using drag and drop. But in reverse direction it paste trash. And from textedit itself paste trash. Problem is in inserting data into clip buffer. It insets it in utf8.

ps: I found. This line

return String(h.begin(), sizeof(char16) * h.GetCount());

should looks like this:

return String((char*)h.begin(), sizeof(char16) * h.GetCount());
<!-- gh-comment-id:1097106127 --> @kov-serg commented on GitHub (Apr 12, 2022): Did you check result? ![pic-02](https://user-images.githubusercontent.com/5946122/163034566-088fb7bd-45e0-4c1f-865f-f2765c155713.png) ![pic-03](https://user-images.githubusercontent.com/5946122/163034571-d2404339-a1f7-4d90-aef9-77a16a88976e.png) From wordpad text inserted without problem using drag and drop. But in reverse direction it paste trash. And from textedit itself paste trash. Problem is in inserting data into clip buffer. It insets it in utf8. ps: I found. This [line](https://github.com/ultimatepp/ultimatepp/blob/master/uppsrc/CtrlCore/Win32Clip.cpp#L282) ``` return String(h.begin(), sizeof(char16) * h.GetCount()); ``` should looks like this: ``` return String((char*)h.begin(), sizeof(char16) * h.GetCount()); ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/ultimatepp#38
No description provided.