• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BathyScapheで画像のインラインプレビューを可能にするプラグイン


Commit MetaInfo

Revision3947f54314d2cd784bbabe20a4444a91435824d3 (tree)
Time2012-05-20 13:28:21
Authormasakih <masakih@user...>
Commitermasakih

Log Message

[Mod] selfNotifiedの増減をスレッドセーフに

Change Summary

Incremental Difference

--- a/Ex/BSIPEReplacer.m
+++ b/Ex/BSIPEReplacer.m
@@ -96,6 +96,19 @@ id keyForTextView(NSTextView *view)
9696 [super dealloc];
9797 }
9898
99+- (void)notyfySelf
100+{
101+ @synchronized(self) {
102+ self.selfNotified++;
103+ }
104+}
105+- (void)processNotify
106+{
107+ @synchronized(self) {
108+ self.selfNotified--;
109+ }
110+}
111+
99112 NSRange fixRange(NSRange range, NSTextStorage *ts)
100113 {
101114 NSRange fixedRange = {0,0};
@@ -121,7 +134,7 @@ NSRange fixRange(NSRange range, NSTextStorage *ts)
121134 range:range];
122135
123136 [ts insertAttributedString:newInsertion atIndex:range.location];
124- self.selfNotified++;
137+ [self notyfySelf];
125138 }
126139 [ts endEditing];
127140 }
@@ -134,7 +147,7 @@ NSRange fixRange(NSRange range, NSTextStorage *ts)
134147 return;
135148 }
136149 if(self.selfNotified > 0) {
137- self.selfNotified--;
150+ [self processNotify];
138151 return;
139152 }
140153