mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48: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();
|
splashScreen = new SplashScreen();
|
||||||
|
|
||||||
//load model on background thread (using progress bar to report progress)
|
//load model on background thread (using progress bar to report progress)
|
||||||
new Thread(new Runnable() {
|
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
FModel.initialize(splashScreen.getProgressBar());
|
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() {
|
private void afterDbLoaded() {
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ public class FThreads {
|
|||||||
GuiBase.getInterface().invokeInEdtAndWait(proc);
|
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() {
|
public static boolean isGuiThread() {
|
||||||
return GuiBase.getInterface().isGuiThread();
|
return GuiBase.getInterface().isGuiThread();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import forge.interfaces.IProgressBar;
|
|||||||
import forge.interfaces.ITextField;
|
import forge.interfaces.ITextField;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
import forge.util.ThreadUtil;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ public abstract class GuiDownloadService implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
//invalidate image cache so newly downloaded images will be loaded
|
//invalidate image cache so newly downloaded images will be loaded
|
||||||
GuiBase.getInterface().clearImageCache();
|
GuiBase.getInterface().clearImageCache();
|
||||||
ThreadUtil.invokeInGameThread(this);
|
FThreads.invokeInBackgroundThread(GuiDownloadService.this);
|
||||||
btnStart.setEnabled(false);
|
btnStart.setEnabled(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -87,8 +86,8 @@ public abstract class GuiDownloadService implements Runnable {
|
|||||||
cmdClose = cmdClose0;
|
cmdClose = cmdClose0;
|
||||||
onUpdate = onUpdate0;
|
onUpdate = onUpdate0;
|
||||||
|
|
||||||
// Free up the EDT by assembling card list on the game thread
|
// Free up the EDT by assembling card list on a background thread
|
||||||
ThreadUtil.invokeInGameThread(new Runnable() {
|
FThreads.invokeInBackgroundThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user