fix crash on settings change

Now changing settings globally or per game doesn't crash the app. Works on the fly, without crashing.
This commit is contained in:
izzy2lost
2025-09-02 10:36:29 -04:00
parent 82e9ea45d7
commit 7f04373064
5 changed files with 212 additions and 61 deletions
@@ -825,10 +825,24 @@ public class MainActivity extends AppCompatActivity implements GamesCoverDialogF
private void updateRendererButtonLabel() {
MaterialButton btn_bios = findViewById(R.id.btn_bios);
if (btn_bios != null) {
btn_bios.setText(rendererShortLabel(getCurrentRendererPref()));
int current = getCurrentRendererPref();
try {
// Prefer runtime renderer from core to reflect per-game overrides
int runtime = NativeApp.getCurrentRenderer();
// Only accept expected values
if (runtime == -1 || runtime == 12 || runtime == 13 || runtime == 14) {
current = runtime;
}
} catch (Throwable ignored) {}
btn_bios.setText(rendererShortLabel(current));
}
}
// Public minimal UI refresh hook for dialogs
public void refreshQuickUi() {
updateRendererButtonLabel();
}
private void setRendererAndSave(int renderer) {
SharedPreferences prefs = getSharedPreferences("app_prefs", MODE_PRIVATE);
prefs.edit().putInt("renderer", renderer).apply();