File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -810,8 +810,11 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
810
810
// Open the clipboard
811
811
OpenClipboard (NULL );
812
812
813
- // Get the clipboard's data and put it into a char array
814
- const wchar_t * ClipboardBuffer = reinterpret_cast <const wchar_t *>(GetClipboardData (CF_UNICODETEXT));
813
+ // Get the clipboard's data and lock it
814
+ HANDLE hClipData = GetClipboardData (CF_UNICODETEXT);
815
+ const wchar_t * ClipboardBuffer = nullptr ;
816
+ if (hClipData)
817
+ ClipboardBuffer = static_cast <const wchar_t *>(GlobalLock (hClipData));
815
818
816
819
// Check to make sure we have valid data.
817
820
if (ClipboardBuffer)
@@ -828,6 +831,8 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
828
831
// Don't paste if we're read only
829
832
if (WndEdit->isReadOnly ())
830
833
{
834
+ if (hClipData)
835
+ GlobalUnlock (hClipData);
831
836
CloseClipboard ();
832
837
return true ;
833
838
}
@@ -843,6 +848,8 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
843
848
// Don't paste if we're read only
844
849
if (WndEdit->isReadOnly ())
845
850
{
851
+ if (hClipData)
852
+ GlobalUnlock (hClipData);
846
853
CloseClipboard ();
847
854
return true ;
848
855
}
@@ -947,6 +954,9 @@ bool CGUI_Impl::Event_KeyDown(const CEGUI::EventArgs& Args)
947
954
}
948
955
}
949
956
957
+ if (hClipData)
958
+ GlobalUnlock (hClipData);
959
+
950
960
// Close the clipboard
951
961
CloseClipboard ();
952
962
}
You can’t perform that action at this time.
0 commit comments