Last active
August 10, 2018 21:23
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const nsAString& myTitle = NS_LITERAL_STRING("abc"); | |
int len = myTitle.Length(); | |
printf("Langth %d\n", len); | |
auto callback = Callback < ITypedEventHandler<DataTransferManager*, DataRequestedEventArgs* >> ( | |
[&](IDataTransferManager*, IDataRequestedEventArgs* pArgs) -> HRESULT | |
{ | |
printf("Callback called\n"); | |
printf("Langth %d\n", len); | |
}); | |
dtm->add_DataRequested(callback.Get(), &dataRequestedToken); | |
dtmInterop->ShowShareUIForWindow(hwnd); | |
// RESULTS IN | |
Langth 3 | |
Callback called | |
Langth 1808471329 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
repeating what Chris Swan pointed out in email, this captures
len
by reference and once the stack unwinds will result in a crash. fix by capturing by value[&]
->[len]