-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rmlui_static_cast to assert validity of down casts, see #514
Employ it around the library for extra debug checks (only with rtti enabled).
- Loading branch information
Showing
9 changed files
with
33 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ class DemoWindow : public Rml::EventListener { | |
document->GetElementById("title")->SetInnerRML(title); | ||
|
||
// Add sandbox default text. | ||
if (auto source = static_cast<Rml::ElementFormControl*>(document->GetElementById("sandbox_rml_source"))) | ||
if (auto source = rmlui_dynamic_cast<Rml::ElementFormControl*>(document->GetElementById("sandbox_rml_source"))) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mikke89
Author
Owner
|
||
{ | ||
auto value = source->GetValue(); | ||
value += "<p>Write your RML here</p>\n\n<!-- <img src=\"assets/high_scores_alien_1.tga\"/> -->"; | ||
|
@@ -100,7 +100,7 @@ class DemoWindow : public Rml::EventListener { | |
} | ||
|
||
// Add sandbox style sheet text. | ||
if (auto source = static_cast<Rml::ElementFormControl*>(document->GetElementById("sandbox_rcss_source"))) | ||
if (auto source = rmlui_dynamic_cast<Rml::ElementFormControl*>(document->GetElementById("sandbox_rcss_source"))) | ||
{ | ||
Rml::String value = "/* Write your RCSS here */\n\n/* body { color: #fea; background: #224; }\nimg { image-color: red; } */"; | ||
source->SetValue(value); | ||
|
@@ -332,7 +332,7 @@ class DemoEventListener : public Rml::EventListener { | |
} | ||
else if (value == "tween_duration") | ||
{ | ||
float value = (float)std::atof(static_cast<Rml::ElementFormControl*>(element)->GetValue().c_str()); | ||
float value = (float)std::atof(rmlui_static_cast<Rml::ElementFormControl*>(element)->GetValue().c_str()); | ||
tweening_parameters.duration = value; | ||
if (auto el_duration = element->GetElementById("duration")) | ||
el_duration->SetInnerRML(CreateString(20, "%2.2f", value)); | ||
|
@@ -381,15 +381,15 @@ class DemoEventListener : public Rml::EventListener { | |
} | ||
else if (value == "set_sandbox_body") | ||
{ | ||
if (auto source = static_cast<Rml::ElementFormControl*>(element->GetElementById("sandbox_rml_source"))) | ||
if (auto source = rmlui_dynamic_cast<Rml::ElementFormControl*>(element->GetElementById("sandbox_rml_source"))) | ||
{ | ||
auto value = source->GetValue(); | ||
demo_window->SetSandboxBody(value); | ||
} | ||
} | ||
else if (value == "set_sandbox_style") | ||
{ | ||
if (auto source = static_cast<Rml::ElementFormControl*>(element->GetElementById("sandbox_rcss_source"))) | ||
if (auto source = rmlui_dynamic_cast<Rml::ElementFormControl*>(element->GetElementById("sandbox_rcss_source"))) | ||
{ | ||
auto value = source->GetValue(); | ||
demo_window->SetSandboxStylesheet(value); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Did you mean to change this from static to dynamic cast? Instead of
rmlui_static_cast()
?Same for line 103.