mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
fixed possible NPE
This commit is contained in:
parent
cce8974b24
commit
17e18c184b
1 changed files with 7 additions and 3 deletions
|
@ -48,10 +48,13 @@ abstract class ZLTextViewBase extends ZLView {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZLTextMetrics metrics() {
|
private ZLTextMetrics metrics() {
|
||||||
if (myMetrics == null) {
|
// this local variable is used to guarantee null will not
|
||||||
|
// be returned from this method enen in multi-thread environment
|
||||||
|
ZLTextMetrics m = myMetrics;
|
||||||
|
if (m == null) {
|
||||||
final ZLTextStyleCollection collection = getTextStyleCollection();
|
final ZLTextStyleCollection collection = getTextStyleCollection();
|
||||||
final ZLTextBaseStyle base = collection.getBaseStyle();
|
final ZLTextBaseStyle base = collection.getBaseStyle();
|
||||||
myMetrics = new ZLTextMetrics(
|
m = new ZLTextMetrics(
|
||||||
ZLibrary.Instance().getDisplayDPI(),
|
ZLibrary.Instance().getDisplayDPI(),
|
||||||
collection.getDefaultFontSize(),
|
collection.getDefaultFontSize(),
|
||||||
base.getFontSize(),
|
base.getFontSize(),
|
||||||
|
@ -62,8 +65,9 @@ abstract class ZLTextViewBase extends ZLView {
|
||||||
// TODO: screen area height
|
// TODO: screen area height
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
myMetrics = m;
|
||||||
}
|
}
|
||||||
return myMetrics;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int getWordHeight() {
|
final int getWordHeight() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue