Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Core/GDCore/Project/ObjectFolderOrObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "GDCore/Serialization/SerializerElement.h"
#include "GDCore/String.h"
#include "GDCore/Project/QuickCustomization.h"
#include "GDCore/Project/MemoryTrackedRegistry.h"

namespace gd {
class Project;
Expand Down Expand Up @@ -214,6 +215,8 @@ class GD_CORE_API ObjectFolderOrObject {
gd::String folderName; // Empty if object is set.
std::vector<std::unique_ptr<ObjectFolderOrObject>>
children; // Folder children.

gd::MemoryTracked _memoryTracked{this, "ObjectFolderOrObject"};
};

} // namespace gd
1 change: 1 addition & 0 deletions GDevelop.js/Bindings/postjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ patchClassesForUseAfterFreeDetection(Module, {
'EffectsContainer',
'InitialInstancesContainer',
'LayersContainer',
'ObjectFolderOrObject',
'ObjectGroupsContainer',
'ObjectsContainer',
'VariablesContainer',
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/MainFrame/MemoryTrackedRegistryDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const trackedClasses = [
'EffectsContainer',
'InitialInstancesContainer',
'LayersContainer',
'ObjectFolderOrObject',
'ObjectGroupsContainer',
'ObjectsContainer',
'VariablesContainer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { renderQuickCustomizationMenuItems } from '../QuickCustomization/QuickCu
import { type MessageDescriptor } from '../Utils/i18n/MessageDescriptor.flow';
import type { ObjectWithContext } from '../ObjectsList/EnumerateObjects';
import { type HTMLDataset } from '../Utils/HTMLDataset';
import { exceptionallyGuardAgainstDeadObject } from '../Utils/IsNullPtr';

const gd: libGDevelop = global.gd;

Expand Down Expand Up @@ -139,10 +140,12 @@ export class ObjectFolderTreeViewItemContent implements TreeViewItemContent {
}

getName(): string | React.Node {
if (!exceptionallyGuardAgainstDeadObject(this.objectFolder)) return '';
return this.objectFolder.getFolderName();
}

getId(): string {
// getObjectFolderTreeViewItemId only uses .ptr, so it's safe even if dead.
return getObjectFolderTreeViewItemId(this.objectFolder);
}

Expand All @@ -151,6 +154,7 @@ export class ObjectFolderTreeViewItemContent implements TreeViewItemContent {
}

getDataSet(): ?HTMLDataset {
if (!exceptionallyGuardAgainstDeadObject(this.objectFolder)) return null;
return {
folderName: this.objectFolder.getFolderName(),
global: this._isGlobal.toString(),
Expand Down
7 changes: 7 additions & 0 deletions newIDE/app/src/ObjectsList/ObjectTreeViewItemContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { type ObjectEditorTab } from '../ObjectEditor/ObjectEditorDialog';
import type { ObjectWithContext } from '../ObjectsList/EnumerateObjects';
import { type HTMLDataset } from '../Utils/HTMLDataset';
import { isVariantEditable } from '../ObjectEditor/Editors/CustomObjectPropertiesEditor';
import { exceptionallyGuardAgainstDeadObject } from '../Utils/IsNullPtr';

const gd: libGDevelop = global.gd;

Expand Down Expand Up @@ -209,6 +210,7 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
}

is3D(): boolean {
if (!exceptionallyGuardAgainstDeadObject(this.object)) return false;
const objectMetadata = gd.MetadataProvider.getObjectMetadata(
this.props.project.getCurrentPlatform(),
this.object.getObject().getType()
Expand All @@ -217,10 +219,13 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
}

getName(): string | React.Node {
if (!exceptionallyGuardAgainstDeadObject(this.object)) return '';
return this.object.getObject().getName();
}

getId(): string {
if (!exceptionallyGuardAgainstDeadObject(this.object))
return `deleted-${this.object.ptr}`;
return getObjectTreeViewItemId(this.object.getObject());
}

Expand All @@ -229,13 +234,15 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
}

getDataSet(): ?HTMLDataset {
if (!exceptionallyGuardAgainstDeadObject(this.object)) return null;
return {
objectName: this.object.getObject().getName(),
global: this._isGlobal.toString(),
};
}

getThumbnail(): ?string {
if (!exceptionallyGuardAgainstDeadObject(this.object)) return null;
return this.props.getThumbnail(
this.props.project,
this.object.getObject().getConfiguration()
Expand Down
4 changes: 4 additions & 0 deletions newIDE/app/src/ObjectsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { type HTMLDataset } from '../Utils/HTMLDataset';
import type { MessageDescriptor } from '../Utils/i18n/MessageDescriptor.flow';
import type { EventsScope } from '../InstructionOrExpression/EventsScope';
import { type InstallAssetOutput } from '../AssetStore/InstallAsset';
import { exceptionallyGuardAgainstDeadObject } from '../Utils/IsNullPtr';

const gd: libGDevelop = global.gd;

Expand Down Expand Up @@ -245,6 +246,9 @@ class ObjectFolderTreeViewItem implements TreeViewItem {
}

getChildren(i18n: I18nType): ?Array<TreeViewItem> {
if (!exceptionallyGuardAgainstDeadObject(this.objectFolderOrObject))
return this.placeholder ? [this.placeholder] : [];

if (this.objectFolderOrObject.getChildrenCount() === 0) {
return this.placeholder ? [this.placeholder] : [];
}
Expand Down
Loading