Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
djinni
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
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
cpp-libs
djinni
Commits
1dc5a248
Commit
1dc5a248
authored
May 17, 2016
by
Andrew Twyman
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #230 from j4cbo/weakref-create-leak
Don't leak local refs when creating WeakReference objects.
parents
191940c8
ab6b4f63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
support-lib/jni/djinni_support.cpp
support-lib/jni/djinni_support.cpp
+4
-4
No files found.
support-lib/jni/djinni_support.cpp
View file @
1dc5a248
...
...
@@ -489,19 +489,19 @@ private:
};
// Helper used by constructor
static
jobject
create
(
JNIEnv
*
jniEnv
,
jobject
obj
)
{
static
GlobalRef
<
jobject
>
create
(
JNIEnv
*
jniEnv
,
jobject
obj
)
{
const
JniInfo
&
weakRefClass
=
JniClass
<
JniInfo
>::
get
();
jobject
weakRef
=
jniEnv
->
NewObject
(
weakRefClass
.
clazz
.
get
(),
weakRefClass
.
constructor
,
obj
);
LocalRef
<
jobject
>
weakRef
(
jniEnv
,
jniEnv
->
NewObject
(
weakRefClass
.
clazz
.
get
(),
weakRefClass
.
constructor
,
obj
)
);
// DJINNI_ASSERT performs an exception check before anything else, so we don't need
// a separate jniExceptionCheck call.
DJINNI_ASSERT
(
weakRef
,
jniEnv
);
return
weakRef
;
return
GlobalRef
<
jobject
>
(
jniEnv
,
weakRef
)
;
}
public:
// Constructor
JavaWeakRef
(
jobject
obj
)
:
JavaWeakRef
(
jniGetThreadEnv
(),
obj
)
{}
JavaWeakRef
(
JNIEnv
*
jniEnv
,
jobject
obj
)
:
m_weakRef
(
jniEnv
,
create
(
jniEnv
,
obj
))
{}
JavaWeakRef
(
JNIEnv
*
jniEnv
,
jobject
obj
)
:
m_weakRef
(
create
(
jniEnv
,
obj
))
{}
// Get the object pointed to if it's still strongly reachable or, return null if not.
// (Analogous to weak_ptr::lock.) Returns a local reference.
...
...
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