Skip to content

Commit 0a7913e

Browse files
committed
Fix crash when opening AddFunctionDialog
1 parent 727cf8c commit 0a7913e

9 files changed

Lines changed: 28 additions & 20 deletions

File tree

3DRadSpace/3DRadSpace_Editor_WindowsDX11/Frontend/Controls/EventControl.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ EventControl::EventControl(
1010
HINSTANCE hInstance,
1111
int x,
1212
int y,
13-
Engine3DRadSpace::Reflection::Event* event
13+
Engine3DRadSpace::Reflection::Event* event,
14+
Engine3DRadSpace::Objects::ObjectList* list
1415
) : IControl(owner, hInstance),
15-
_event(event)
16+
_event(event),
17+
_list(list)
1618
{
1719
HDC hdc = GetDC(owner);
1820

@@ -40,7 +42,7 @@ EventControl::EventControl(
4042
x + 10,
4143
y + textSize.cy + 10,
4244
260 - sgnTextSize.cx,
43-
480,
45+
370,
4446
owner,
4547
nullptr,
4648
hInstance,
@@ -55,8 +57,8 @@ EventControl::EventControl(
5557
WS_VISIBLE | WS_CHILD,
5658
btnPosX,
5759
y + textSize.cy + 10,
58-
textSize.cx + 5,
59-
textSize.cy + 5,
60+
(2 * sgnTextSize.cx) + 5,
61+
sgnTextSize.cy + 5,
6062
owner,
6163
nullptr,
6264
hInstance,
@@ -65,12 +67,12 @@ EventControl::EventControl(
6567

6668
_btnRemoveCall = CreateWindowExA(0,
6769
"Button",
68-
"-",
70+
"-",
6971
WS_VISIBLE | WS_CHILD,
7072
btnPosX,
7173
y + textSize.cy + 10 + sgnTextSize.cy + 5,
72-
textSize.cx + 5,
73-
textSize.cy + 5,
74+
(2 * sgnTextSize.cx) + 5,
75+
sgnTextSize.cy + 5,
7476
owner,
7577
nullptr,
7678
hInstance,
@@ -87,14 +89,15 @@ void EventControl::HandleClick(HWND clickedWindow)
8789
{
8890
std::thread openFnFinderWindow([this]()
8991
{
90-
AddFunctionDialog dialog(this->window, this->instance, nullptr);
92+
AddFunctionDialog dialog(this->window, this->instance, this->_list);
9193
auto event = dialog.ShowDialog();
9294

9395
if (event.has_value())
9496
{
9597

9698
}
9799
});
100+
openFnFinderWindow.detach();
98101
}
99102

100103
if(clickedWindow == _btnRemoveCall)

3DRadSpace/3DRadSpace_Editor_WindowsDX11/Frontend/Controls/EventControl.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
class EventControl : public IControl
66
{
77
Engine3DRadSpace::Reflection::Event* _event;
8-
8+
Engine3DRadSpace::Objects::ObjectList* _list;
9+
910
HWND _groupBox;
1011
HWND _btnAddCall;
1112
HWND _btnRemoveCall;
@@ -20,7 +21,8 @@ class EventControl : public IControl
2021
HINSTANCE hInstance,
2122
int x,
2223
int y,
23-
Engine3DRadSpace::Reflection::Event* event
24+
Engine3DRadSpace::Reflection::Event* event,
25+
Engine3DRadSpace::Objects::ObjectList* list
2426
);
2527

2628
void HandleClick(HWND clickedWindow) override;

3DRadSpace/3DRadSpace_Editor_WindowsDX11/Frontend/Windows/AddFunctionDialog.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,15 @@ AddFunctionDialog::AddFunctionDialog(
7979
HWND owner,
8080
HINSTANCE hInstance,
8181
ObjectList* list
82-
) : Dialog(owner, hInstance, nullptr, "Find object method"),
82+
) : Dialog(owner, hInstance, AddFunctionDialog_DlgProc, "Find object method"),
8383
_list(list)
8484
{
8585
}
8686

8787
std::optional<EventInvocationRepresentation> AddFunctionDialog::ShowDialog()
8888
{
89+
Dialog::ShowDialog(this);
90+
8991
if (_value.FunctionID == std::numeric_limits<size_t>::max() || _value.OwnerObject == std::numeric_limits<size_t>::max())
9092
{
9193
return std::nullopt;

3DRadSpace/3DRadSpace_Editor_WindowsDX11/Frontend/Windows/EditObjectDialog.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "..\Controls\SoundControl.hpp"
1313
#include <Engine3DRadSpace/Projects/EventInvocationRepresentation.hpp>
1414
#include "../Controls/EventControl.hpp"
15+
#include <Engine3DRadSpace/Objects/ObjectList.hpp>
1516

1617
using namespace Engine3DRadSpace;
1718
using namespace Engine3DRadSpace::Audio;
@@ -510,7 +511,9 @@ void EditObjectDialog::createForms()
510511
{
511512
const Event* value = reinterpret_cast<const Event*>(reinterpret_cast<const char*>(valuePtr) + fOffset);
512513

513-
EventControl* ctrl = new EventControl(window, hInstance, x, y, const_cast<Event*>(value));
514+
auto objList = _content->GetOwner()->RequireService<Objects::ObjectList>({});
515+
516+
EventControl* ctrl = new EventControl(window, hInstance, x, y, const_cast<Event*>(value), objList);
514517
windows.push_back(ctrl);
515518

516519
setMax(inc_y, ctrl->AccY() + 5 + textboxHeight);

3DRadSpace/3DRadSpace_Editor_WindowsDX11/Frontend/Windows/EditorWindow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void EditorWindow::_openProject(const std::filesystem::path& filename)
6464
void EditorWindow::PopulateObjectList(Engine3DRadSpace::Objects::ObjectList* list, HWND treeView)
6565
{
6666
std::unordered_map<IObject*, HTREEITEM> objectToTreeItem;
67-
for (int i = 0; auto& instance : *(list))
67+
for (int i = 0; auto& instance : *list)
6868
{
6969
auto object = instance.Object.get();
7070

@@ -185,7 +185,7 @@ void EditorWindow::_findUpdate()
185185
//Check version
186186
if (version == EngineVersion)
187187
{
188-
MessageBoxA(_mainWindow, "No new updates were found.", "Update information", MB_ICONINFORMATION | MB_OK);
188+
//MessageBoxA(_mainWindow, "No new updates were found.", "Update information", MB_ICONINFORMATION | MB_OK);
189189
return;
190190
}
191191

2.01 MB
Loading

3DRadSpace/Engine3DRadSpace/Content/ContentManager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ IAsset* ContentManager::AssetFactory::Create(const Reflection::UUID& uuid, const
2626
return nullptr;
2727
}
2828

29-
ContentManager::ContentManager(IGame* owner) :
29+
ContentManager::ContentManager(IGame* owner) : IService(owner),
3030
_lastID(1),
31-
_factory(owner),
32-
_owner(owner)
31+
_factory(owner)
3332
{
3433
//We add a null asset at index 0 because reference IDs are unsigned integers.
3534
_assets.emplace_back(nullptr);

3DRadSpace/Engine3DRadSpace/Content/ContentManager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ namespace Engine3DRadSpace::Content
121121

122122
unsigned _lastID;
123123
std::vector<AssetEntry> _assets;
124-
IGame* _owner;
125124
public:
126125
/// <summary>
127126
/// Constructs an instance of ContentManager.

3DRadSpace/Engine3DRadSpace/Reflection/Event.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ namespace Engine3DRadSpace::Reflection
1818

1919
MemberFunctionInvoker() = default;
2020
MemberFunctionInvoker(void* object, std::unique_ptr<IReflectedFunction> &&fn, std::type_index returnType);
21-
MemberFunctionInvoker(MemberFunctionInvoker&& other) noexcept = default;
2221

22+
MemberFunctionInvoker(MemberFunctionInvoker&& other) noexcept = default;
2323
MemberFunctionInvoker& operator=(MemberFunctionInvoker&& other) noexcept = default;
2424
};
2525

0 commit comments

Comments
 (0)