Skip to content

Commit f326e78

Browse files
committed
Disable function::target if rtti is disabled
1 parent 03593ab commit f326e78

File tree

9 files changed

+33
-6
lines changed

9 files changed

+33
-6
lines changed

examples/showcase/src/Dialogs.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ static RC<Widget> osDialogButton(std::string text, Listener<> fn) {
1717

1818
class SmallComponent : public Component {
1919
public:
20+
~SmallComponent() override = default;
21+
2022
RC<Widget> build() final {
2123
return rcnew Widget{
2224
stylesheet = Graphene::stylesheet(),

include/brisk/core/Binding.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,8 @@ class BindingObject : public Object, public std::enable_shared_from_this<Binding
17501750
using Base = std::enable_shared_from_this<BindingObject<Derived, scheduler>>;
17511751

17521752
public:
1753+
~BindingObject() override {}
1754+
17531755
using Ptr = std::shared_ptr<Derived>;
17541756

17551757
[[nodiscard]] std::shared_ptr<Derived> shared_from_this() {

include/brisk/core/internal/Function.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ template <typename R, typename... Args>
3333
struct fn_base {
3434
virtual ~fn_base() {}
3535

36-
virtual R operator()(Args... args) = 0;
36+
virtual R operator()(Args... args) = 0;
37+
#ifdef BRISK_RTTI
3738
virtual const std::type_info& target_type() const noexcept = 0;
3839
virtual void* target() noexcept = 0;
40+
#endif
3941
};
4042

4143
template <typename Fn, typename R, typename... Args>
@@ -49,13 +51,15 @@ struct fn_impl : public fn_base<R, Args...> {
4951
return fn(std::forward<Args>(args)...);
5052
}
5153

54+
#ifdef BRISK_RTTI
5255
const std::type_info& target_type() const noexcept override {
5356
return typeid(Fn);
5457
}
5558

5659
void* target() noexcept override {
5760
return &fn;
5861
}
62+
#endif
5963

6064
Fn fn;
6165
};
@@ -95,6 +99,7 @@ struct function<R(Args...)> {
9599

96100
std::shared_ptr<fn_base<R, Args...>> impl;
97101

102+
#ifdef BRISK_RTTI
98103
const std::type_info& target_type() const noexcept {
99104
return impl->target_type();
100105
}
@@ -107,6 +112,7 @@ struct function<R(Args...)> {
107112
return nullptr;
108113
}
109114
}
115+
#endif
110116

111117
bool operator==(const function& fn) const noexcept {
112118
return impl == fn.impl;

include/brisk/gui/Component.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace Brisk {
3434
*/
3535
class Component : public BindingObject<Component, &uiScheduler> {
3636
public:
37-
virtual ~Component();
37+
~Component() override {}
3838

3939
/**
4040
* @brief Gets the `GUIWindow` associated with this component.

include/brisk/gui/Groups.hpp

+14
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,45 @@ struct SizeGroup : public WidgetGroup {
2828
public:
2929
constexpr SizeGroup(Orientation orientation) : orientation(orientation) {}
3030

31+
~SizeGroup() override = default;
32+
3133
Orientation orientation;
3234

3335
void beforeLayout(bool dirty) final;
3436
};
3537

3638
struct WidthGroup final : public SizeGroup {
3739
constexpr WidthGroup() : SizeGroup(Orientation::Horizontal) {}
40+
41+
~WidthGroup() override = default;
3842
};
3943

4044
struct HeightGroup final : public SizeGroup {
4145
constexpr HeightGroup() : SizeGroup(Orientation::Vertical) {}
46+
47+
~HeightGroup() override = default;
4248
};
4349

4450
struct VisualGroup : public WidgetGroup {
4551
constexpr VisualGroup(Orientation orientation) : orientation(orientation) {}
4652

53+
~VisualGroup() override = default;
54+
4755
Orientation orientation;
4856

4957
void beforeFrame() final;
5058
};
5159

5260
struct HorizontalVisualGroup final : public VisualGroup {
5361
constexpr HorizontalVisualGroup() : VisualGroup(Orientation::Horizontal) {}
62+
63+
~HorizontalVisualGroup() override = default;
5464
};
5565

5666
struct VerticalVisualGroup final : public VisualGroup {
5767
constexpr VerticalVisualGroup() : VisualGroup(Orientation::Vertical) {}
68+
69+
~VerticalVisualGroup() override = default;
5870
};
5971

6072
template <typename WidgetGroup>
@@ -71,6 +83,8 @@ class WIDGET WidgetWithGroup final : public Widget {
7183
endConstruction();
7284
}
7385

86+
~WidgetWithGroup() override = default;
87+
7488
void append(RC<Widget> widget) override {
7589
if (widget)
7690
widget->apply(&group);

include/brisk/gui/WidgetTree.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class Widget;
3535
struct WidgetGroup {
3636
std::vector<Widget*> widgets;
3737

38-
~WidgetGroup();
38+
virtual ~WidgetGroup() {
39+
clean();
40+
}
3941

4042
virtual void beforeRefresh() {}
4143

@@ -46,6 +48,8 @@ struct WidgetGroup {
4648
virtual void beforePaint() {}
4749

4850
virtual void afterFrame() {}
51+
52+
void clean();
4953
};
5054

5155
using Drawable = function<void(Canvas&)>;

src/core/Binding.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,5 @@ void Bindings::internalDisconnect(const BindingAddresses& addresses, BindDir dir
270270
}
271271
}
272272
}
273+
273274
} // namespace Brisk

src/gui/Component.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
namespace Brisk {
2424

25-
Component::~Component() {}
26-
2725
RC<GUIWindow> Component::window() {
2826
return m_window.lock();
2927
}

src/gui/WidgetTree.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
namespace Brisk {
2525

26-
WidgetGroup::~WidgetGroup() {
26+
void WidgetGroup::clean() {
2727
for (Widget* w : widgets) {
2828
w->removeFromGroup(this);
2929
}

0 commit comments

Comments
 (0)