Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unregister 时有空指针问题 #19

Open
jiantao88 opened this issue Jul 2, 2015 · 9 comments
Open

unregister 时有空指针问题 #19

jiantao88 opened this issue Jul 2, 2015 · 9 comments

Comments

@jiantao88
Copy link

移除注册事件时偶尔会发生空指针现象

@jiantao88
Copy link
Author

07-02 20:10:28.130 E/CrashReport(26443): android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3521)
07-02 20:10:28.130 E/CrashReport(26443): ......
07-02 20:10:28.130 E/CrashReport(26443): cause by:
07-02 20:10:28.130 E/CrashReport(26443): java.lang.NullPointerException:
07-02 20:10:28.130 E/CrashReport(26443): org.simple.eventbus.SubsciberMethodHunter.removeMethodsFromMap(SubsciberMethodHunter.java:133)
07-02 20:10:28.130 E/CrashReport(26443): org.simple.eventbus.EventBus.unregister(EventBus.java:176)

@hehonghui
Copy link
Owner

@jiantao88 是最新版本对吗 ?你是在哪个时机注销的?

@jiantao88
Copy link
Author

是最新的版本,是在onDestory方法里

@wurensen
Copy link

wurensen commented Jul 7, 2015

确实可能会有这个问题,弱引用持有的订阅者,在没有判断不为null的情况下直接比较了

@hehonghui
Copy link
Owner

@wurensen 已经看到这个问题,周末处理一下。

@hehonghui
Copy link
Owner

已经处理了,各位可以看看。当引用对象为空时该Subscription也会被移除;不为空时则会跟传递进来的对象进行判等,如果相等也移除。

@hehonghui
Copy link
Owner

@jiantao88 @wurensen 你们都在产品中用了么 ?

@andrewlu1
Copy link

我想知道能否去掉unregister这一步,能否实现自动取消订阅.
因为有很多场景并不存在成对的onCreate/onDestroy这样的操作的.

@d0ng13
Copy link

d0ng13 commented Jan 14, 2016

@andrewlu1 可以考虑在onResume和onPause时刻去注册和注销

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants