A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/commit/6ba47157f below:

original asset objects are now cast during first load to avoid l… · AlmasB/FXGL@6ba4715 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+9

-2

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+9

-2

lines changed Original file line number Diff line number Diff line change

@@ -533,7 +533,7 @@ class FXGLAssetLoaderService : AssetLoaderService() {

533 533

cachedAssets[cacheKey] = loaded as Any

534 534

}

535 535 536 -

loaded

536 +

data.cast(loaded as Any)

537 537

} catch (e: Exception) {

538 538

log.warning("Failed to load ${loadParams.url}", e)

539 539

data.getDummy()

@@ -696,6 +696,12 @@ private class TextAssetLoader : AssetLoader<List<*>>(

696 696

List::class.java,

697 697

TEXT_DIR

698 698

) {

699 +

override fun cast(obj: Any): List<String> {

700 +

val list = obj as List<String>

701 + 702 +

return list.toList()

703 +

}

704 + 699 705

override fun load(url: URL): List<String> = url.openStream().bufferedReader().readLines()

700 706 701 707

override fun getDummy(): List<String> = emptyList()

Original file line number Diff line number Diff line change

@@ -185,7 +185,8 @@ class AssetLoaderServiceTest {

185 185 186 186

assertThat(lines.size, `is`(0))

187 187 188 -

assertTrue(assetLoader.loadText("test1.txt") === assetLoader.loadText("test1.txt"))

188 +

// ensure a new copy of the list is loaded so that original cannot be modified

189 +

assertTrue(assetLoader.loadText("test1.txt") !== assetLoader.loadText("test1.txt"))

189 190

}

190 191 191 192

@Test

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4