Skip to content

Commit

Permalink
Fixes for NULL pointer dereference (pxscene#930)
Browse files Browse the repository at this point in the history
* Warnings scrub on macOS

* Unified type use for matrix calculations and templates

* Revert "Merge branch 'master' of https://github.com/FitzerIRL/pxCore"

This reverts commit 0fe607b, reversing
changes made to 99063c3.

* Revert "Unified type use for matrix calculations and templates"

This reverts commit 99063c3.

* Added checks for NULL pointers
  • Loading branch information
FitzerIRL authored and mfiess committed Mar 1, 2018
1 parent bfd70e6 commit 3d25163
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/mac/pxClipboardNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,35 @@

std::string pxClipboardNative::getString(std::string type)
{
printf("pxClipboardNative::getString() - ENTER\n");
// printf("pxClipboardNative::getString() - ENTER\n");

NSPasteboard* pasteBoard = [NSPasteboard generalPasteboard];
NSString* myString = [pasteBoard stringForType: NSPasteboardTypeString];


if(myString)
{
return std::string([myString UTF8String]);
}
else
{
return std::string("");
}
}

void pxClipboardNative::setString(std::string type, std::string clip)
{
printf("pxClipboardNative::setString() - ENTER\n");
// printf("pxClipboardNative::setString() - ENTER\n");

NSString *stringToWrite = [NSString stringWithUTF8String: clip.c_str()];


if(stringToWrite)
{
NSPasteboard* pasteBoard = [NSPasteboard generalPasteboard];

[pasteBoard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pasteBoard setString:stringToWrite forType:NSStringPboardType];
if(pasteBoard)
{
[pasteBoard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pasteBoard setString:stringToWrite forType:NSStringPboardType];
}
}
}
6 changes: 6 additions & 0 deletions src/mac/pxWindowNative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,11 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender

pxClipboardNative *clip = pxClipboardNative::instance();

if(clip && dropURL)
{
clip->setString("TEXT", [dropURL UTF8String]);
}
}
else
{
// Handle Drag'n'Dropped >> TEXT
Expand All @@ -835,7 +838,10 @@ - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender

pxClipboardNative *clip = pxClipboardNative::instance();

if(clip && text)
{
clip->setString("TEXT", [text UTF8String]);
}
}

pxWindowNative::_helper_onKeyDown(mWindow, 86, 16); // Fake a CTRL-V
Expand Down

0 comments on commit 3d25163

Please sign in to comment.