registry must be not used here because not yet initialized

GitOrigin-RevId: 19d3c617dcfb340c29cf6780429343637c2cd000
This commit is contained in:
Vladimir Krivosheev
2019-05-29 21:14:12 +03:00
committed by intellij-monorepo-bot
parent ebf02771d4
commit 87ad9d1fa9
4 changed files with 30 additions and 14 deletions
@@ -115,8 +115,6 @@ ide.javafx.tips.description=(Experimental) Use JavaFX Browser for 'Tips of the D
ide.index.image.max.size=10
ide.index.image.max.size.description=Max size of an image to index, in megabytes
ide.cached.image.max.size=1.5
ide.cached.image.max.size.description=Max size of an image to cache, in megabytes
no.window.actions.in.editor=false
no.window.actions.in.editor.description=Disables window actions "Stretch to.." within focused editor as before.
@@ -73,6 +73,18 @@ public class SystemProperties {
return defaultValue;
}
public static float getFloatProperty(@NotNull String key, float defaultValue) {
String value = System.getProperty(key);
if (value != null) {
try {
return Float.parseFloat(value);
}
catch (NumberFormatException ignored) {
}
}
return defaultValue;
}
/**
* Returns the value of given property as a boolean, or {@code defaultValue} if the property is not specified or malformed.
*/
@@ -7,7 +7,6 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayInputStream;
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.util.containers.ContainerUtil;
@@ -42,9 +41,12 @@ import static com.intellij.util.ui.JBUIScale.DerivedScaleType.PIX_SCALE;
import static com.intellij.util.ui.JBUIScale.ScaleType.OBJ_SCALE;
public class ImageLoader implements Serializable {
private static final Logger LOG = Logger.getInstance("#com.intellij.util.ImageLoader");
@NotNull
private static Logger getLogger() {
return Logger.getInstance("#com.intellij.util.ImageLoader");
}
public static final long CACHED_IMAGE_MAX_SIZE = (long)(Registry.doubleValue("ide.cached.image.max.size") * 1024 * 1024);
public static final long CACHED_IMAGE_MAX_SIZE = (long)(SystemProperties.getFloatProperty("ide.cached.image.max.size", 1.5f) * 1024 * 1024);
private static final ConcurrentMap<String, Pair<Image, Dimension2D>> ourCache = ContainerUtil.createConcurrentSoftValueMap();
public static void clearCache() {
@@ -106,7 +108,7 @@ public class ImageLoader implements Serializable {
// Either {inputStream} or {path} should be defined
if (stream == null) {
if (StringUtil.isEmpty(path)) {
LOG.warn("empty image path", new Throwable());
getLogger().warn("empty image path", new Throwable());
return null;
}
@@ -201,7 +203,7 @@ public class ImageLoader implements Serializable {
return image;
}
catch (Exception ex) {
LOG.error(ex);
getLogger().error(ex);
}
return null;
}
@@ -274,8 +276,11 @@ public class ImageLoader implements Serializable {
for (ImageDesc desc : this) {
try {
Image image = desc.load(useCache);
if (image == null) continue;
LOG.debug("Loaded image: " + desc);
if (image == null) {
continue;
}
getLogger().debug("Loaded image: " + desc);
return converters.convert(image, desc);
}
catch (IOException ignore) {
@@ -391,7 +396,7 @@ public class ImageLoader implements Serializable {
mediatracker.waitForID(1, 5000);
}
catch (InterruptedException ex) {
LOG.info(ex);
getLogger().info(ex);
}
return !mediatracker.isErrorID(1);
}
@@ -530,7 +535,7 @@ public class ImageLoader implements Serializable {
return ImageConverterChain.create().withFilter(filter).withHiDPI(ctx).convert(image, desc);
}
catch (IOException ex) {
LOG.error(ex);
getLogger().error(ex);
}
return null;
}
@@ -544,7 +549,7 @@ public class ImageLoader implements Serializable {
final int h = icon.getHeight(null);
if (w <= 0 || h <= 0) {
LOG.error("negative image size: w=" + w + ", h=" + h + ", path=" + f.getPath());
getLogger().error("negative image size: w=" + w + ", h=" + h + ", path=" + f.getPath());
return null;
}
@@ -12,7 +12,6 @@ import com.intellij.ui.JBColor;
import com.intellij.ui.border.CustomLineBorder;
import com.intellij.util.LazyInitializer.MutableNotNullValue;
import com.intellij.util.LazyInitializer.NullableValue;
import com.intellij.util.ObjectUtils;
import com.intellij.util.SystemProperties;
import com.intellij.util.ui.JBUIScale.DerivedScaleType;
import com.intellij.util.ui.JBUIScale.Scale;
@@ -122,7 +121,9 @@ public class JBUI {
@Override
protected void onInitialized(@Nullable Float scale) {
if (isNotNull()) setUserScaleFactor(ObjectUtils.notNull(scale));
if (isNotNull()) {
setUserScaleFactor(scale);
}
}
};