Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
Closes #1629

*CL* *Added*: hs.midi

- Added in a check to make sure `source` isn’t an empty NSArray
  • Loading branch information
latenitefilms authored and cmsj committed Dec 25, 2017
1 parent f0b66f3 commit fcc5967
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Hammerspoon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@
22613FE51F297B9B00E05E11 /* init.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = init.lua; path = extensions/dialog/init.lua; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.lua; };
22613FF11F297E0D00E05E11 /* libdialog.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libdialog.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
22E4D7F71FA7485A00C8CF5C /* internal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = internal.m; path = extensions/midi/internal.m; sourceTree = SOURCE_ROOT; };
22E4D7F81FA7485A00C8CF5C /* init.lua */ = {isa = PBXFileReference; lastKnownFileType = text; name = init.lua; path = extensions/midi/init.lua; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.lua; };
22E4D7F81FA7485A00C8CF5C /* init.lua */ = {isa = PBXFileReference; lastKnownFileType = text; name = init.lua; path = extensions/midi/init.lua; sourceTree = SOURCE_ROOT; };
22E4D8021FA7488900C8CF5C /* libmidi.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libmidi.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
22E4D8071FA74BDA00C8CF5C /* libMIKMIDI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libMIKMIDI.a; sourceTree = BUILT_PRODUCTS_DIR; };
4C3D55A91C7F05D00023B633 /* init.lua */ = {isa = PBXFileReference; lastKnownFileType = text; path = init.lua; sourceTree = "<group>"; };
Expand Down
9 changes: 9 additions & 0 deletions extensions/midi/internal.m
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,15 @@ static int midi_callback(lua_State *L) {
// Setup MIDI Device End Point:
//
NSArray *source = [device.entities valueForKeyPath:@"@unionOfArrays.sources"];
if (source.count == 0) {
//
// This shouldn't happen, but if it does, catch the error:
//
[skin logError:[NSString stringWithFormat:@"%s:callback error:%@", USERDATA_TAG, @"No MIDI Device End Points detected."]] ;
wrapper.callbackToken = nil;
lua_pushvalue(L, 1);
return 1;
}
MIKMIDISourceEndpoint *endpoint = [source objectAtIndex:0];

//
Expand Down

0 comments on commit fcc5967

Please sign in to comment.