mirror of https://github.com/buggins/dlangui.git
resource cleanup fixed
This commit is contained in:
parent
e76394c5da
commit
abb5417819
|
@ -40,6 +40,8 @@ extern (C) int UIAppMain(string[] args) {
|
|||
|
||||
// create window
|
||||
Window window = Platform.instance().createWindow("My Window", null);
|
||||
|
||||
static if (false) {
|
||||
LinearLayout layout = new LinearLayout();
|
||||
layout.addChild((new TextWidget()).textColor(0x00802000).text("Text widget 0"));
|
||||
layout.addChild((new TextWidget()).textColor(0x40FF4000).text("Text widget"));
|
||||
|
@ -79,6 +81,9 @@ extern (C) int UIAppMain(string[] args) {
|
|||
layout.layoutHeight(FILL_PARENT).layoutWidth(FILL_PARENT);
|
||||
|
||||
window.mainWidget = layout;
|
||||
} else {
|
||||
window.mainWidget = (new Button()).text("sample button");
|
||||
}
|
||||
window.show();
|
||||
window.windowCaption = "New Window Caption";
|
||||
|
||||
|
|
|
@ -699,11 +699,17 @@ class SolidFillDrawable : Drawable {
|
|||
class ImageDrawable : Drawable {
|
||||
protected DrawBufRef _image;
|
||||
protected bool _tiled;
|
||||
private int _instanceCount;
|
||||
this(ref DrawBufRef image, bool tiled = false, bool ninePatch = false) {
|
||||
_image = image;
|
||||
_tiled = tiled;
|
||||
if (ninePatch)
|
||||
_image.detectNinePatch();
|
||||
Log.d("Created ImageDrawable, count=", ++_instanceCount);
|
||||
}
|
||||
~this() {
|
||||
_image.clear();
|
||||
Log.d("Destroyed ImageDrawable, count=", --_instanceCount);
|
||||
}
|
||||
@property override int width() {
|
||||
if (_image.isNull)
|
||||
|
|
|
@ -475,7 +475,7 @@ class FreeTypeFontManager : FontManager {
|
|||
return best;
|
||||
}
|
||||
|
||||
private FontList _activeFonts;
|
||||
//private FontList _activeFonts;
|
||||
|
||||
private static FontRef _nullFontRef;
|
||||
|
||||
|
@ -490,13 +490,14 @@ class FreeTypeFontManager : FontManager {
|
|||
}
|
||||
}
|
||||
~this() {
|
||||
Log.d("FreeTypeFontManager ~this() active fonts: ", _activeFonts.length);
|
||||
_activeFonts.clear();
|
||||
Log.d("FreeTypeFontManager ~this()");
|
||||
//_activeFonts.clear();
|
||||
foreach(ref FontFileItem item; _fontFiles) {
|
||||
destroy(item);
|
||||
item = null;
|
||||
}
|
||||
_fontFiles.length = 0;
|
||||
Log.d("Destroyed all fonts. Freeing library.");
|
||||
// uninit library
|
||||
if (_library)
|
||||
FT_Done_FreeType(_library);
|
||||
|
|
|
@ -72,6 +72,11 @@ class ImageCache {
|
|||
}
|
||||
~this() {
|
||||
Log.i("Destroying ImageCache");
|
||||
foreach (ref item; _map) {
|
||||
destroy(item);
|
||||
item = null;
|
||||
}
|
||||
_map.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,14 +113,17 @@ class DrawableCache {
|
|||
bool _error;
|
||||
bool _used;
|
||||
DrawableRef _drawable;
|
||||
private int _instanceCount;
|
||||
this(string id, string filename, bool tiled) {
|
||||
_id = id;
|
||||
_filename = filename;
|
||||
_tiled = tiled;
|
||||
_error = filename is null;
|
||||
Log.d("Created DrawableCacheItem, count=", ++_instanceCount);
|
||||
}
|
||||
~this() {
|
||||
_drawable.clear();
|
||||
Log.d("Destroyed DrawableCacheItem, count=", --_instanceCount);
|
||||
}
|
||||
/// remove from memory, will cause reload on next access
|
||||
void compact() {
|
||||
|
@ -213,6 +221,11 @@ class DrawableCache {
|
|||
}
|
||||
~this() {
|
||||
Log.i("Destroying DrawableCache");
|
||||
foreach (ref item; _idToDrawableMap) {
|
||||
destroy(item);
|
||||
item = null;
|
||||
}
|
||||
_idToDrawableMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -472,6 +472,11 @@ class Theme : Style {
|
|||
|
||||
~this() {
|
||||
Log.d("Theme destructor");
|
||||
foreach(ref Style item; _byId) {
|
||||
destroy(item);
|
||||
item = null;
|
||||
}
|
||||
_byId.clear();
|
||||
}
|
||||
|
||||
/// create wrapper style which will have currentTheme.get(id) as parent instead of fixed parent - to modify some base style properties in widget
|
||||
|
@ -520,6 +525,10 @@ class Theme : Style {
|
|||
return _byId[id];
|
||||
return this;
|
||||
}
|
||||
|
||||
void dumpStats() {
|
||||
Log.d("Theme ", _id, ": children:", _children.length, ", substates:", _substates.length, ", mapsize:", _byId.length);
|
||||
}
|
||||
}
|
||||
|
||||
/// to access current theme
|
||||
|
@ -542,6 +551,7 @@ Theme createDefaultTheme() {
|
|||
button.createState(State.Disabled, State.Disabled).backgroundImageId("btn_default_small_normal_disable");
|
||||
button.createState(State.Pressed, State.Pressed).backgroundImageId("btn_default_small_pressed");
|
||||
button.createState(State.Focused, State.Focused).backgroundImageId("btn_default_small_selected");
|
||||
res.dumpStats();
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue