mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-28 01:43:22 +08:00
fix for crash when switching tabs in dev console
This commit is contained in:
parent
a2ea720bb9
commit
feb010f497
56
.efrocachemap
generated
56
.efrocachemap
generated
@ -4056,26 +4056,26 @@
|
||||
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
|
||||
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
|
||||
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "6cdefa5cd565abee912694fb28d828d3",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "c51444bf5d10839e45a347c3200a6055",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "0ab2bbf81b5a23d9cd0df2c8c71d1df8",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "767696047eb3faa9dcab8edcef4e776b",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "18ef5fd23969bbd009bb1360a161fca4",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "680935c4c7d3cfe1d74afdb5376c55a2",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "7fd4da4a5ef6ed013fad3e5ab360cbae",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "65fa11a84646d483601ee37a0c1ba653",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "530214ddb822998dfdb61107dded1802",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "52924ddffd34be9cb9b78ef4757a7f45",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "a9b3849992aa832e2265f626e46773f4",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "e56702bd5e1fd7e5c613ea6dd4b8801a",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "c96db4026b4ff8d7b2f6fd189778db50",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "de5638c952f8d71b26235f30bc957f2c",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "17d898335005122c303ea1811dd06c77",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "0941c6dfb7b7a5ebfc0e4e8f93cb3fb7",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "cdcdb3a9fc357e025ce2ed6d864a0e80",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "d68b729ed88d9eef64bc1a40cc34b67f",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "fa3cd09737f23271f66ca7d7bb1e629a",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "4ea0a028f40afc4456135f34a95d652b",
|
||||
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "6d1f9c2c53c02a35d87bb0aea62f7408",
|
||||
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "cfbf3e80472077cbccc98b681d24e7cd",
|
||||
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "7af76def8c480e88ddd6257ab4d0dfff",
|
||||
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "6c3372ab5283cbd91362c23a32629ee5",
|
||||
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "80f3683bc192c94a6d1a1dc2137f0844",
|
||||
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "9fb5cc47cfd4bf4c717acf3877dde233",
|
||||
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "095a758aacb5940b793d82dddc142d34",
|
||||
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "f312f5066c8bc883a24b0e3a86884bb3",
|
||||
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "b9f8a78b14d439e8ace4c70e18ae9e19",
|
||||
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "5a25d4de9c3124822538602fb9273280",
|
||||
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "7ea84daf12222b10517bf71870b82b53",
|
||||
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "28dba23a69dc1159cf340f899f78f4d9",
|
||||
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "3b653a753ac0cb919431528908c9cccc",
|
||||
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "9df409c73fb121b4d5fcd0fde6d4e42f",
|
||||
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "be64f13a639454d8b82311dcfd6815e0",
|
||||
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "f713443831ee2d9f912ca3c5e10201d8",
|
||||
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "6135e6256411bf24e44834d3445f94af",
|
||||
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "e782b975adada7282b5aaa6b1b1b0e1d",
|
||||
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "142aa10ee8c2747b011ef18062d5de48",
|
||||
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "01d7543c88bf94b9478b261003c5521c",
|
||||
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "dd14e0abacf5a27d9823b0a41127e3e3",
|
||||
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "bd994ca8a1896ada5c582be155db5c36",
|
||||
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "dd14e0abacf5a27d9823b0a41127e3e3",
|
||||
@ -4092,14 +4092,14 @@
|
||||
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "7d386ab4fc78cc7598188df82bf4f04a",
|
||||
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "5627e6b08b61024650420b849d41721b",
|
||||
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "7d386ab4fc78cc7598188df82bf4f04a",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "36dc4b524796e12a1bda3dd96cc5a102",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "6e97a4ada89c867ea6795b792a37091a",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "1aeee25b763b80b7f291e5adfd025557",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "6903271f88d2a904fb0394e99098f746",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "c2888b185b9ac3ddae1db665839765b5",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "e7a19af8da2c3910080d411a11429723",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "9093de58a5aa33b8061057ac500a3f6d",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "93dcf1b0a3d140c51eb550e6d95128d1",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "cc3c3f837962636cbcd542b9b54946f2",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "b6a9ccfc44c215d7f31e985bbc8eab06",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "056a71331f28fbe6a07ae4086e3e8391",
|
||||
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "ae9f5d7069310cb18f7dfc90ad207203",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "b014ca1f2fec594cb149f11d783ee165",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "2085834b3d1523f6e29cd89011d4c062",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "aa9fadf3a2410df7b5aca9c88194cfcc",
|
||||
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "d6ccc0796e64abab851caac47ce54a86",
|
||||
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
|
||||
"src/assets/ba_data/python/babase/_mgen/enums.py": "f8cd3af311ac63147882590123b78318",
|
||||
"src/ballistica/base/mgen/pyembed/binding_base.inc": "9f71f171464dc004dbaab87e9bb4b03b",
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
### 1.7.28 (build 21421, api 8, 2023-10-05)
|
||||
### 1.7.28 (build 21422, api 8, 2023-10-05)
|
||||
|
||||
- Massively cleaned up code related to rendering and window systems (OpenGL,
|
||||
SDL, etc). This code had been growing into a nasty tangle for 15 years
|
||||
|
||||
@ -52,7 +52,7 @@ if TYPE_CHECKING:
|
||||
|
||||
# Build number and version of the ballistica binary we expect to be
|
||||
# using.
|
||||
TARGET_BALLISTICA_BUILD = 21421
|
||||
TARGET_BALLISTICA_BUILD = 21422
|
||||
TARGET_BALLISTICA_VERSION = '1.7.28'
|
||||
|
||||
|
||||
|
||||
@ -137,6 +137,25 @@ static void DrawText(RenderPass* pass, TextGroup* tgrp, float tscale,
|
||||
}
|
||||
}
|
||||
|
||||
/// Anyone iterating through or mucking with the UI lists should hold one
|
||||
/// of these while doing so; they simply keep us informed if we're editing
|
||||
/// UI stuff where we shouldn't be.
|
||||
class DevConsole::ScopedUILock_ {
|
||||
public:
|
||||
explicit ScopedUILock_(DevConsole* dev_console) : dev_console_{dev_console} {
|
||||
assert(g_base->InLogicThread());
|
||||
dev_console_->ui_lock_count_++;
|
||||
}
|
||||
~ScopedUILock_() {
|
||||
assert(g_base->InLogicThread());
|
||||
dev_console_->ui_lock_count_--;
|
||||
assert(dev_console_->ui_lock_count_ >= 0);
|
||||
}
|
||||
|
||||
private:
|
||||
DevConsole* dev_console_;
|
||||
};
|
||||
|
||||
/// Super-simple widget type for populating dev-console
|
||||
/// (we don't want to depend on any of our full UI feature-sets).
|
||||
class DevConsole::Widget_ {
|
||||
@ -393,6 +412,12 @@ class DevConsole::TabButton_ : public DevConsole::Widget_ {
|
||||
if (pressed) {
|
||||
pressed = false;
|
||||
if (InUs(mx, my)) {
|
||||
// Technically this callback should cause us to be recreated in a
|
||||
// selected state, but that happens in a deferred call, so go ahead
|
||||
// and set ourself as selected already so we don't flash as
|
||||
// unselected for a frame before the deferred call runs.
|
||||
selected = true;
|
||||
|
||||
if (call.Exists()) {
|
||||
call.Get()->Run();
|
||||
}
|
||||
@ -450,6 +475,11 @@ DevConsole::DevConsole() {
|
||||
DevConsole::~DevConsole() = default;
|
||||
|
||||
void DevConsole::RefreshTabButtons_() {
|
||||
// IMPORTANT: This code should always be run in its own top level call and
|
||||
// never directly from user code. Otherwise we can wind up mucking with
|
||||
// the UI list as we're iterating through it.
|
||||
assert(!ui_lock_count_);
|
||||
|
||||
// Ask the Python layer for the latest set of tabs.
|
||||
tabs_ = g_base->python->objs()
|
||||
.Get(BasePython::ObjID::kGetDevConsoleTabNamesCall)
|
||||
@ -482,8 +512,12 @@ void DevConsole::RefreshTabButtons_() {
|
||||
tab, active_tab_ == tab, bscale, DevConsoleHAnchor_::kCenter, x,
|
||||
-bheight, bwidth, bheight, [this, tab] {
|
||||
active_tab_ = tab;
|
||||
RefreshTabButtons_();
|
||||
RefreshTabContents_();
|
||||
// Can't muck with UI from code called while iterating through UI.
|
||||
// So defer it.
|
||||
g_base->logic->event_loop()->PushCall([this] {
|
||||
RefreshTabButtons_();
|
||||
RefreshTabContents_();
|
||||
});
|
||||
}));
|
||||
x += bwidth;
|
||||
}
|
||||
@ -492,6 +526,11 @@ void DevConsole::RefreshTabButtons_() {
|
||||
void DevConsole::RefreshTabContents_() {
|
||||
BA_PRECONDITION(g_base->InLogicThread());
|
||||
|
||||
// IMPORTANT: This code should always be run in its own top level call and
|
||||
// never directly from user code. Otherwise we can wind up mucking with
|
||||
// the UI list as we're iterating through it.
|
||||
assert(!ui_lock_count_);
|
||||
|
||||
// Consider any refresh requests fulfilled. Subsequent refresh-requests
|
||||
// will generate a new refresh at this point.
|
||||
refresh_pending_ = false;
|
||||
@ -567,6 +606,9 @@ auto DevConsole::HandleMouseDown(int button, float x, float y) -> bool {
|
||||
|
||||
// Pass to any buttons (in bottom-local space).
|
||||
if (button == 1) {
|
||||
// Make sure we don't muck with our UI while we're in here.
|
||||
auto lock = ScopedUILock_(this);
|
||||
|
||||
for (auto&& button : tab_buttons_) {
|
||||
if (button->HandleMouseDown(x, y - bottom)) {
|
||||
return true;
|
||||
@ -603,6 +645,9 @@ void DevConsole::HandleMouseUp(int button, float x, float y) {
|
||||
float bottom{Bottom_()};
|
||||
|
||||
if (button == 1) {
|
||||
// Make sure we don't muck with our UI while we're in here.
|
||||
auto lock = ScopedUILock_(this);
|
||||
|
||||
for (auto&& button : tab_buttons_) {
|
||||
button->HandleMouseUp(x, y - bottom);
|
||||
}
|
||||
@ -813,12 +858,18 @@ void DevConsole::ToggleState() {
|
||||
switch (state_) {
|
||||
case State_::kInactive:
|
||||
state_ = State_::kMini;
|
||||
RefreshTabButtons_();
|
||||
RefreshTabContents_();
|
||||
// Can't muck with UI from code (potentially) called while iterating
|
||||
// through UI. So defer it.
|
||||
g_base->logic->event_loop()->PushCall([this] {
|
||||
RefreshTabButtons_();
|
||||
RefreshTabContents_();
|
||||
});
|
||||
break;
|
||||
case State_::kMini:
|
||||
state_ = State_::kFull;
|
||||
RefreshTabContents_();
|
||||
// Can't muck with UI from code (potentially) called while iterating
|
||||
// through UI. So defer it.
|
||||
g_base->logic->event_loop()->PushCall([this] { RefreshTabContents_(); });
|
||||
break;
|
||||
case State_::kFull:
|
||||
state_ = State_::kInactive;
|
||||
@ -1104,6 +1155,9 @@ void DevConsole::Draw(FrameDef* frame_def) {
|
||||
|
||||
// Tab Buttons.
|
||||
{
|
||||
// Make sure we don't muck with our UI while we're in here.
|
||||
auto lock = ScopedUILock_(this);
|
||||
|
||||
for (auto&& button : tab_buttons_) {
|
||||
button->Draw(pass, bottom);
|
||||
}
|
||||
@ -1111,6 +1165,9 @@ void DevConsole::Draw(FrameDef* frame_def) {
|
||||
|
||||
// Buttons.
|
||||
{
|
||||
// Make sure we don't muck with our UI while we're in here.
|
||||
auto lock = ScopedUILock_(this);
|
||||
|
||||
for (auto&& button : widgets_) {
|
||||
button->Draw(pass, bottom);
|
||||
}
|
||||
@ -1133,6 +1190,11 @@ auto DevConsole::BaseScale() const -> float {
|
||||
|
||||
void DevConsole::StepDisplayTime() {
|
||||
assert(g_base->InLogicThread());
|
||||
|
||||
// IMPORTANT: We can muck with UI here so make sure noone is iterating
|
||||
// through or editing it.
|
||||
assert(!ui_lock_count_);
|
||||
|
||||
// If we're inactive, blow away all our stuff once we transition fully
|
||||
// off screen. This will kill any Python stuff attached to our widgets
|
||||
// so things can clean themselves up.
|
||||
|
||||
@ -67,6 +67,7 @@ class DevConsole {
|
||||
void RequestRefresh();
|
||||
|
||||
private:
|
||||
class ScopedUILock_;
|
||||
class Widget_;
|
||||
class Button_;
|
||||
class Text_;
|
||||
@ -87,6 +88,7 @@ class DevConsole {
|
||||
bool python_terminal_visible_{};
|
||||
bool python_terminal_pressed_{};
|
||||
bool refresh_pending_{};
|
||||
int ui_lock_count_{};
|
||||
State_ state_{State_::kInactive};
|
||||
State_ state_prev_{State_::kInactive};
|
||||
millisecs_t last_input_text_change_time_{};
|
||||
|
||||
@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
|
||||
namespace ballistica {
|
||||
|
||||
// These are set automatically via script; don't modify them here.
|
||||
const int kEngineBuildNumber = 21421;
|
||||
const int kEngineBuildNumber = 21422;
|
||||
const char* kEngineVersion = "1.7.28";
|
||||
const int kEngineApiVersion = 8;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user