Skip to content

Instantly share code, notes, and snippets.

@cmsj
Created January 4, 2015 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmsj/bb35a1c3350ae11844d8 to your computer and use it in GitHub Desktop.
Save cmsj/bb35a1c3350ae11844d8 to your computer and use it in GitHub Desktop.
diff --git a/Hammerspoon/MJConsoleWindowController.m b/Hammerspoon/MJConsoleWindowController.m
index ea234d0..c54561a 100644
--- a/Hammerspoon/MJConsoleWindowController.m
+++ b/Hammerspoon/MJConsoleWindowController.m
@@ -84,7 +84,10 @@ typedef NS_ENUM(NSUInteger, MJReplLineType) {
NSDictionary* attrs = @{NSFontAttributeName: [NSFont fontWithName:@"Menlo" size:12.0], NSForegroundColorAttributeName: color};
NSAttributedString* attrstr = [[NSAttributedString alloc] initWithString:str attributes:attrs];
- [[self.outputView textStorage] appendAttributedString:attrstr];
+ [[self.outputView textStorage] performSelectorOnMainThread:@selector(appendAttributedString:)
+ withObject:attrstr
+ waitUntilDone:YES];
+ //[[self.outputView textStorage] appendAttributedString:attrstr];
}
- (NSString*) run:(NSString*)command {
diff --git a/extensions/screen/watcher.m b/extensions/screen/watcher.m
index 77b4af8..646fc97 100644
--- a/extensions/screen/watcher.m
+++ b/extensions/screen/watcher.m
@@ -40,6 +40,12 @@ static NSMutableIndexSet* screenHandlers;
@end
@implementation MJScreenWatcher
+- (void) _screensChanged:(id __unused)bla {
+ [self performSelectorOnMainThread:@selector(screensChanged:)
+ withObject:nil
+ waitUntilDone:YES];
+}
+
- (void) screensChanged:(id __unused)bla {
lua_State* L = self.L;
lua_getglobal(L, "debug"); lua_getfield(L, -1, "traceback"); lua_remove(L, -2);
@@ -100,7 +106,7 @@ static int screen_watcher_start(lua_State* L) {
screenwatcher->registryHandle = store_udhandler(L, screenHandlers, 1);
[[NSNotificationCenter defaultCenter] addObserver:(__bridge id)screenwatcher->obj
- selector:@selector(screensChanged:)
+ selector:@selector(_screensChanged:)
name:NSApplicationDidChangeScreenParametersNotification
object:nil];
diff --git a/extensions/wifi/watcher.m b/extensions/wifi/watcher.m
index f403293..929b67c 100644
--- a/extensions/wifi/watcher.m
+++ b/extensions/wifi/watcher.m
@@ -48,6 +48,12 @@ static NSMutableIndexSet* wifiHandlers;
return self;
}
+- (void) _ssidChanged:(id __unused)bla {
+ [self performSelectorOnMainThread:@selector(ssidChanged:)
+ withObject:nil
+ waitUntilDone:YES];
+}
+
- (void) ssidChanged:(id __unused)bla {
lua_State* L = self.L;
lua_getglobal(L, "debug"); lua_getfield(L, -1, "traceback"); lua_remove(L, -2);
@@ -116,7 +122,7 @@ static int wifi_watcher_start(lua_State* L) {
wifiwatcher->registryHandle = store_udhandler(L, wifiHandlers, 1);
[[NSNotificationCenter defaultCenter] addObserver:(__bridge id)wifiwatcher->obj
- selector:@selector(ssidChanged:)
+ selector:@selector(_ssidChanged:)
name:CWSSIDDidChangeNotification
object:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment