mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Fix so downloader doesn't cause infinite loop
This commit is contained in:
@@ -74,7 +74,7 @@ public class Forge implements ApplicationListener {
|
||||
splashScreen = new SplashScreen();
|
||||
|
||||
//load model on background thread (using progress bar to report progress)
|
||||
new Thread(new Runnable() {
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FModel.initialize(splashScreen.getProgressBar());
|
||||
@@ -91,7 +91,7 @@ public class Forge implements ApplicationListener {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Game Startup").start(); //use thread name that starts with "Game" so GuiMobile.isGuiThread() returns false
|
||||
});
|
||||
}
|
||||
|
||||
private void afterDbLoaded() {
|
||||
|
||||
@@ -53,6 +53,13 @@ public class FThreads {
|
||||
GuiBase.getInterface().invokeInEdtAndWait(proc);
|
||||
}
|
||||
|
||||
private static int backgroundThreadCount;
|
||||
public static void invokeInBackgroundThread(final Runnable proc) {
|
||||
//start thread name with "Game" so isGuiThread() returns false on GuiMobile
|
||||
new Thread(proc, "Game BT" + backgroundThreadCount).start();
|
||||
backgroundThreadCount++;
|
||||
}
|
||||
|
||||
public static boolean isGuiThread() {
|
||||
return GuiBase.getInterface().isGuiThread();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import forge.interfaces.IProgressBar;
|
||||
import forge.interfaces.ITextField;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.ThreadUtil;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -60,7 +59,7 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
public void run() {
|
||||
//invalidate image cache so newly downloaded images will be loaded
|
||||
GuiBase.getInterface().clearImageCache();
|
||||
ThreadUtil.invokeInGameThread(this);
|
||||
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
||||
btnStart.setEnabled(false);
|
||||
}
|
||||
};
|
||||
@@ -87,8 +86,8 @@ public abstract class GuiDownloadService implements Runnable {
|
||||
cmdClose = cmdClose0;
|
||||
onUpdate = onUpdate0;
|
||||
|
||||
// Free up the EDT by assembling card list on the game thread
|
||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
||||
// Free up the EDT by assembling card list on a background thread
|
||||
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user