Use std::enable_shared_from_this instead of thisP parameters.

This commit is contained in:
Twan van Laarhoven
2020-05-06 22:59:10 +02:00
parent b4435e5e57
commit e005d47d56
20 changed files with 114 additions and 118 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ DataEditor::DataEditor(Window* parent, int id, long style)
}
ValueViewerP DataEditor::makeViewer(const StyleP& style) {
return style->makeEditor(*this, style);
return style->makeEditor(*this);
}
// ----------------------------------------------------------------------------- : Utility for ValueViewers
+1 -1
View File
@@ -504,7 +504,7 @@ void ConsolePanel::exec(String const& command) {
ScriptType type = result->type();
if (type == SCRIPT_IMAGE) {
GeneratedImage::Options options(0,0, set->stylesheet.get(), set.get());
wxImage image = result->toImage(result)->generate(options);
wxImage image = result->toImage()->generate(options);
message->bitmap = wxBitmap(image);
} else if (type == SCRIPT_COLOR) {
message->text = result->toCode();
+1 -1
View File
@@ -152,7 +152,7 @@ void DropDownChoiceListBase::generateThumbnailImages() {
try {
String name = canonical_name_form(field().choices->choiceName(i));
ctx.setVariable(_("input"), to_script(name));
GeneratedImageP img = image_from_script(style().image.getValidScriptP()->eval(ctx));
GeneratedImageP img = style().image.getValidScriptP()->eval(ctx)->toImage();
style().choice_images.insert(make_pair(name, ScriptableImage(img)));
} catch (const Error& e) {
handle_error(Error(e.what() + _("\n while generating choice images for drop down list")));
+2 -3
View File
@@ -144,9 +144,8 @@ class ValueEditor {
public:
#define IMPLEMENT_VALUE_EDITOR(Type) \
ValueViewerP Type##Style::makeEditor(DataEditor& parent, const StyleP& thisP) { \
assert(thisP.get() == this); \
return ValueViewerP(new Type##ValueEditor(parent, static_pointer_cast<Type##Style>(thisP))); \
ValueViewerP Type##Style::makeEditor(DataEditor& parent) { \
return ValueViewerP(new Type##ValueEditor(parent, static_pointer_cast<Type##Style>(intrusive_from_this()))); \
} \
Type##ValueEditor::Type##ValueEditor(DataEditor& parent, const Type##StyleP& style) \
: Type##ValueViewer(parent, style)