Android: use try(resource) to auto-close in case of resource error
Change-Id: I0a57df1b18ec9da8f673d295172cf9dd8c179c4c Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
This commit is contained in:
parent
da04c85e9c
commit
fbf5123371
@ -107,8 +107,10 @@ class CursorHandle implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
Context context = m_layout.getContext();
|
Context context = m_layout.getContext();
|
||||||
int[] attrs = {m_attr};
|
int[] attrs = {m_attr};
|
||||||
TypedArray a = context.getTheme().obtainStyledAttributes(attrs);
|
Drawable drawable;
|
||||||
Drawable drawable = a.getDrawable(0);
|
try (TypedArray a = context.getTheme().obtainStyledAttributes(attrs)) {
|
||||||
|
drawable = a.getDrawable(0);
|
||||||
|
}
|
||||||
|
|
||||||
m_cursorView = new CursorView(context, this);
|
m_cursorView = new CursorView(context, this);
|
||||||
m_cursorView.setImageDrawable(drawable);
|
m_cursorView.setImageDrawable(drawable);
|
||||||
|
@ -123,9 +123,11 @@ class QtMessageDialogHelper
|
|||||||
private Drawable getStyledDrawable(int id)
|
private Drawable getStyledDrawable(int id)
|
||||||
{
|
{
|
||||||
int[] attrs = { id };
|
int[] attrs = { id };
|
||||||
final TypedArray a = m_theme.obtainStyledAttributes(attrs);
|
Drawable d;
|
||||||
Drawable d = a.getDrawable(0);
|
try (TypedArray a = m_theme.obtainStyledAttributes(attrs)) {
|
||||||
a.recycle();
|
d = a.getDrawable(0);
|
||||||
|
a.recycle();
|
||||||
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user