Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Commit

Permalink
Add a build script to kill current running XIME instances.
Browse files Browse the repository at this point in the history
Rewrite updateComposition: and cancelComposition: methods in inputController. SDK provided version causes crash when using ARC.
  • Loading branch information
stackia committed Oct 24, 2014
1 parent 1850fa7 commit 83fc6c7
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
15 changes: 15 additions & 0 deletions XIME.xcodeproj/project.pbxproj
Expand Up @@ -561,6 +561,7 @@
C13DA3D519F30F27004B2348 /* Copy opencc Dictionary Files */,
C13DA3DE19F31359004B2348 /* Copy Library Files */,
C1A26E2619F4D0EB007BF527 /* Auto Increase Build Number */,
C107775E19FA5AAC00D3E673 /* Kill Running XIME Instances */,
);
buildRules = (
C19AE36719F3E75900592E35 /* PBXBuildRule */,
Expand Down Expand Up @@ -652,6 +653,20 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
C107775E19FA5AAC00D3E673 /* Kill Running XIME Instances */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Kill Running XIME Instances";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#!/bin/bash\n(kill $(ps aux | grep '[X]IME' | awk '{print $2}')) 2>/dev/null || true";
};
C1A26E2619F4D0EB007BF527 /* Auto Increase Build Number */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
1 change: 0 additions & 1 deletion XIME/Source/AppDelegate.m
Expand Up @@ -15,7 +15,6 @@ @implementation AppDelegate
#pragma mark Application Delegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

// Create IMKServer
if ([IMKServer sharedServer] == nil) {
NSLog(@"Failed to create IMKServer.");
Expand Down
10 changes: 3 additions & 7 deletions XIME/Source/CandidateWindowController.m
Expand Up @@ -27,14 +27,13 @@ - (void)updateWithRimeContext:(XRimeContext *)context caretRect:(NSRect)caretRec
// Hide window
[[self window] orderOut:self];
} else {
const int verticalOffet = 5;

// Resize window
NSRect windowRect = [[self window] frame];

// Reposition window
windowRect.origin.x = NSMinX(caretRect);
windowRect.origin.y = NSMinY(caretRect) - NSHeight(caretRect) - verticalOffet;
windowRect.origin.y = NSMaxY(caretRect) + kXIMECandidateWindowPositionVerticalOffset;

// Fit in current screen
NSRect screenRect = [[NSScreen mainScreen] frame];
Expand All @@ -54,13 +53,10 @@ - (void)updateWithRimeContext:(XRimeContext *)context caretRect:(NSRect)caretRec
windowRect.origin.x = NSMinX(screenRect);
}
if (NSMinY(windowRect) < NSMinY(screenRect)) {
windowRect.origin.y = NSMaxY(caretRect) + verticalOffet;
windowRect.origin.y = NSMinY(screenRect);
}
if (NSMaxY(windowRect) > NSMaxY(screenRect)) {
windowRect.origin.y = NSMaxY(screenRect) - NSHeight(windowRect);
}
if (NSMinY(windowRect) < NSMinY(screenRect)) {
windowRect.origin.y = NSMinY(screenRect);
windowRect.origin.y = NSMinY(caretRect) - NSHeight(windowRect) - kXIMECandidateWindowPositionVerticalOffset;
}

// Show window
Expand Down
11 changes: 11 additions & 0 deletions XIME/Source/InputController.m
Expand Up @@ -202,6 +202,17 @@ - (NSRange)selectionRange {
return NSMakeRange(cursorPosition_, 0);
}

// Rewrite this method because the original one will crash when using ARC
- (void)updateComposition {
NSAttributedString *composedString = [self composedString:self];
[[self client] setMarkedText:composedString selectionRange:[self selectionRange] replacementRange:[self replacementRange]];
}

// Rewrite this method because the original one will crash when using ARC
- (void)cancelComposition {
[[self client] insertText:[self originalString:self] replacementRange:[self replacementRange]];
}

This comment has been minimized.

Copy link
@pkamb

pkamb Dec 29, 2015

Thank you! Very good to get some confirmation on the crashes my input method is experiencing.

- (id)initWithServer:(IMKServer *)server delegate:(id)delegate client:(id)inputClient {
if (self = [super initWithServer:server delegate:delegate client:inputClient]) {
rimeSessionId_ = [RimeWrapper createSession]; // Try to create Rime session
Expand Down
2 changes: 1 addition & 1 deletion XIME/Supporting Files/Info.plist
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>198</string>
<string>222</string>
<key>InputMethodConnectionName</key>
<string>com.Stackia.inputmethod.XIME.IMKConnection</string>
<key>InputMethodServerControllerClass</key>
Expand Down
2 changes: 2 additions & 0 deletions XIME/Supporting Files/XIME.pch
Expand Up @@ -14,6 +14,8 @@
#import <Cocoa/Cocoa.h>
#endif

// All const definitions here
#define kXIMEUserDataDirectoryKey @"XIMEUserDataDirectory"
#define kXIMECandidateWindowPositionVerticalOffset 5;

#endif

0 comments on commit 83fc6c7

Please sign in to comment.