Merge pull request #56842 from Chaosus/fix_assetlib_crash

This commit is contained in:
Rémi Verschelde 2022-01-17 12:25:54 +01:00 committed by GitHub
commit 56e79052b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View File

@ -398,10 +398,9 @@ void EditorAssetLibraryItemDownload::configure(const String &p_title, int p_asse
void EditorAssetLibraryItemDownload::_notification(int p_what) { void EditorAssetLibraryItemDownload::_notification(int p_what) {
switch (p_what) { switch (p_what) {
// FIXME: The editor crashes if 'NOTICATION_THEME_CHANGED' is used.
case NOTIFICATION_ENTER_TREE: case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer"))); panel->add_theme_style_override("panel", get_theme_stylebox(SNAME("panel"), SNAME("TabContainer")));
dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons"))); dismiss->set_normal_texture(get_theme_icon(SNAME("Close"), SNAME("EditorIcons")));
} break; } break;
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
@ -494,8 +493,11 @@ void EditorAssetLibraryItemDownload::_bind_methods() {
} }
EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() { EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
panel = memnew(PanelContainer);
add_child(panel);
HBoxContainer *hb = memnew(HBoxContainer); HBoxContainer *hb = memnew(HBoxContainer);
add_child(hb); panel->add_child(hb);
icon = memnew(TextureRect); icon = memnew(TextureRect);
hb->add_child(icon); hb->add_child(icon);
@ -543,16 +545,16 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
set_custom_minimum_size(Size2(310, 0) * EDSCALE); set_custom_minimum_size(Size2(310, 0) * EDSCALE);
download = memnew(HTTPRequest); download = memnew(HTTPRequest);
add_child(download); panel->add_child(download);
download->connect("request_completed", callable_mp(this, &EditorAssetLibraryItemDownload::_http_download_completed)); download->connect("request_completed", callable_mp(this, &EditorAssetLibraryItemDownload::_http_download_completed));
setup_http_request(download); setup_http_request(download);
download_error = memnew(AcceptDialog); download_error = memnew(AcceptDialog);
add_child(download_error); panel->add_child(download_error);
download_error->set_title(TTR("Download Error")); download_error->set_title(TTR("Download Error"));
asset_installer = memnew(EditorAssetInstaller); asset_installer = memnew(EditorAssetInstaller);
add_child(asset_installer); panel->add_child(asset_installer);
asset_installer->connect("confirmed", callable_mp(this, &EditorAssetLibraryItemDownload::_close)); asset_installer->connect("confirmed", callable_mp(this, &EditorAssetLibraryItemDownload::_close));
prev_status = -1; prev_status = -1;

View File

@ -126,9 +126,10 @@ public:
EditorAssetLibraryItemDescription(); EditorAssetLibraryItemDescription();
}; };
class EditorAssetLibraryItemDownload : public PanelContainer { class EditorAssetLibraryItemDownload : public Control {
GDCLASS(EditorAssetLibraryItemDownload, PanelContainer); GDCLASS(EditorAssetLibraryItemDownload, Control);
PanelContainer *panel;
TextureRect *icon; TextureRect *icon;
Label *title; Label *title;
ProgressBar *progress; ProgressBar *progress;