Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
7172ef62
Commit
7172ef62
authored
May 21, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NPE on initialization of Bot
parent
2ba31871
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/BotImpl.kt
...rc/commonMain/kotlin/net/mamoe/mirai/qqandroid/BotImpl.kt
+2
-12
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
+11
-1
No files found.
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/BotImpl.kt
View file @
7172ef62
...
...
@@ -32,18 +32,8 @@ import kotlin.time.measureTime
internal
abstract
class
BotImpl
<
N
:
BotNetworkHandler
>
constructor
(
context
:
Context
,
val
configuration
:
BotConfiguration
)
:
Bot
(),
CoroutineScope
{
final
override
val
coroutineContext
:
CoroutineContext
=
configuration
.
parentCoroutineContext
+
SupervisorJob
(
configuration
.
parentCoroutineContext
[
Job
])
+
(
configuration
.
parentCoroutineContext
[
CoroutineExceptionHandler
]
?:
CoroutineExceptionHandler
{
_
,
e
->
logger
.
error
(
"An exception was thrown under a coroutine of Bot"
,
e
)
})
configuration
:
BotConfiguration
)
:
Bot
(
configuration
),
CoroutineScope
{
override
val
context
:
Context
by
context
.
unsafeWeakRef
()
final
override
val
logger
:
MiraiLogger
by
lazy
{
configuration
.
botLoggerSupplier
(
this
)
}
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/Bot.kt
View file @
7172ef62
...
...
@@ -46,7 +46,16 @@ suspend inline fun <B : Bot> B.alsoLogin(): B = also { login() }
* @see BotFactory 构造 [Bot] 的工厂, [Bot] 唯一的构造方式.
*/
@Suppress
(
"INAPPLICABLE_JVM_NAME"
,
"EXPOSED_SUPER_CLASS"
)
abstract
class
Bot
:
CoroutineScope
,
LowLevelBotAPIAccessor
,
BotJavaFriendlyAPI
,
ContactOrBot
{
abstract
class
Bot
(
val
configuration
:
BotConfiguration
)
:
CoroutineScope
,
LowLevelBotAPIAccessor
,
BotJavaFriendlyAPI
,
ContactOrBot
{
final
override
val
coroutineContext
:
CoroutineContext
=
configuration
.
parentCoroutineContext
+
SupervisorJob
(
configuration
.
parentCoroutineContext
[
Job
])
+
(
configuration
.
parentCoroutineContext
[
CoroutineExceptionHandler
]
?:
CoroutineExceptionHandler
{
_
,
e
->
logger
.
error
(
"An exception was thrown under a coroutine of Bot"
,
e
)
})
companion
object
{
@Suppress
(
"ObjectPropertyName"
)
internal
val
_instances
:
LockFreeLinkedList
<
WeakRef
<
Bot
>>
=
LockFreeLinkedList
()
...
...
@@ -106,6 +115,7 @@ abstract class Bot : CoroutineScope, LowLevelBotAPIAccessor, BotJavaFriendlyAPI,
* 在 JVM 的默认实现为 `class ContextImpl : Context`
* 在 Android 实现为 `android.content.Context`
*/
@MiraiExperimentalAPI
abstract
val
context
:
Context
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment