Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
e3742a9b
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e3742a9b
编写于
10月 14, 2019
作者:
G
gaaclarke
提交者:
GitHub
10月 14, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iOS Platform View: Fixed overrelease of the observer. (#13093)
上级
3fd87771
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
10 deletion
+43
-10
shell/platform/darwin/ios/platform_view_ios.h
shell/platform/darwin/ios/platform_view_ios.h
+15
-1
shell/platform/darwin/ios/platform_view_ios.mm
shell/platform/darwin/ios/platform_view_ios.mm
+28
-9
未找到文件。
shell/platform/darwin/ios/platform_view_ios.h
浏览文件 @
e3742a9b
...
...
@@ -48,6 +48,20 @@ class PlatformViewIOS final : public PlatformView {
void
SetSemanticsEnabled
(
bool
enabled
)
override
;
private:
/// Smart pointer for use with objective-c observers.
/// This guarentees we remove the observer.
class
ScopedObserver
{
public:
ScopedObserver
();
~
ScopedObserver
();
void
reset
(
id
<
NSObject
>
observer
);
ScopedObserver
(
const
ScopedObserver
&
)
=
delete
;
ScopedObserver
&
operator
=
(
const
ScopedObserver
&
)
=
delete
;
private:
id
<
NSObject
>
observer_
;
};
fml
::
WeakPtr
<
FlutterViewController
>
owner_controller_
;
// Since the `ios_surface_` is created on the platform thread but
// used on the GPU thread we need to protect it with a mutex.
...
...
@@ -58,7 +72,7 @@ class PlatformViewIOS final : public PlatformView {
std
::
unique_ptr
<
AccessibilityBridge
>
accessibility_bridge_
;
fml
::
scoped_nsprotocol
<
FlutterTextInputPlugin
*>
text_input_plugin_
;
fml
::
closure
firstFrameCallback_
;
fml
::
scoped_nsprotocol
<
NSObject
*>
dealloc_view_controller_observer_
;
ScopedObserver
dealloc_view_controller_observer_
;
// |PlatformView|
void
HandlePlatformMessage
(
fml
::
RefPtr
<
flutter
::
PlatformMessage
>
message
)
override
;
...
...
shell/platform/darwin/ios/platform_view_ios.mm
浏览文件 @
e3742a9b
...
...
@@ -54,15 +54,15 @@ void PlatformViewIOS::SetOwnerViewController(fml::WeakPtr<FlutterViewController>
// Add an observer that will clear out the owner_controller_ ivar and
// the accessibility_bridge_ in case the view controller is deleted.
dealloc_view_controller_observer_
.
reset
(
[[
NSNotificationCenter
defaultCenter
]
addObserverForName:
FlutterViewControllerWillDealloc
object:
owner_controller_
.
get
()
queue:
[
NSOperationQueue
mainQueue
]
usingBlock:
^
(
NSNotification
*
note
)
{
// Implicit copy of 'this' is fine.
accessibility_bridge_
.
reset
();
owner_controller_
.
reset
();
}
]);
dealloc_view_controller_observer_
.
reset
(
[[[
NSNotificationCenter
defaultCenter
]
addObserverForName
:
FlutterViewControllerWillDealloc
object:
owner_controller_
.
get
()
queue:
[
NSOperationQueue
mainQueue
]
usingBlock:
^
(
NSNotification
*
note
)
{
// Implicit copy of 'this' is fine.
accessibility_bridge_
.
reset
();
owner_controller_
.
reset
();
}]
retain
]);
if
(
owner_controller_
)
{
ios_surface_
=
...
...
@@ -174,4 +174,23 @@ void PlatformViewIOS::SetTextInputPlugin(fml::scoped_nsprotocol<FlutterTextInput
text_input_plugin_
=
plugin
;
}
PlatformViewIOS
::
ScopedObserver
::
ScopedObserver
()
:
observer_
(
nil
)
{}
PlatformViewIOS
::
ScopedObserver
::~
ScopedObserver
()
{
if
(
observer_
)
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
observer_
];
[
observer_
release
];
}
}
void
PlatformViewIOS
::
ScopedObserver
::
reset
(
id
<
NSObject
>
observer
)
{
if
(
observer
!=
observer_
)
{
if
(
observer_
)
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
observer_
];
[
observer_
release
];
}
observer_
=
observer
;
}
}
}
// namespace flutter
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录