Fixed segmentation fault when copying textbox
This commit is contained in:
parent
79f7135746
commit
f0f289d785
13 changed files with 27 additions and 25 deletions
|
|
@ -37,14 +37,14 @@ DrawComponentType DrawBrushStroke::get_type() const {
|
|||
|
||||
#ifndef IS_SERVER
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawBrushStroke::copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawBrushStroke::copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawBrushStroke>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
return a;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawBrushStroke::deep_copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawBrushStroke::deep_copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawBrushStroke>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ class DrawBrushStroke : public DrawComponent {
|
|||
std::shared_ptr<Data> d = std::make_shared<Data>(); // It's a pointer here since brush strokes cant be edited
|
||||
|
||||
#ifndef IS_SERVER
|
||||
virtual std::shared_ptr<DrawComponent> copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const override;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ class DrawComponent {
|
|||
void calculate_world_bounds();
|
||||
virtual SCollision::AABB<float> get_obj_coord_bounds() const = 0;
|
||||
|
||||
virtual std::shared_ptr<DrawComponent> copy() const = 0;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const = 0;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const = 0;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const = 0;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) = 0;
|
||||
void commit_update(DrawingProgram& drawP, bool invalidateCache = true); // invalidateCache = false version should be thread safe
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ void DrawEllipse::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber
|
|||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawEllipse::copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawEllipse::copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawEllipse>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
return a;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawEllipse::deep_copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawEllipse::deep_copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawEllipse>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class DrawEllipse : public DrawComponent {
|
|||
} d;
|
||||
|
||||
#ifndef IS_SERVER
|
||||
virtual std::shared_ptr<DrawComponent> copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const override;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ void DrawImage::remap_resource_ids(std::unordered_map<ServerClientID, ServerClie
|
|||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawImage::copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawImage::copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawImage>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
return a;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawImage::deep_copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawImage::deep_copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawImage>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class DrawImage : public DrawComponent {
|
|||
} d;
|
||||
|
||||
#ifndef IS_SERVER
|
||||
virtual std::shared_ptr<DrawComponent> copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const override;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ void DrawRectangle::load_file(cereal::PortableBinaryInputArchive& a, VersionNumb
|
|||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawRectangle::copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawRectangle::copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawRectangle>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
return a;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawRectangle::deep_copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawRectangle::deep_copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawRectangle>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ class DrawRectangle : public DrawComponent {
|
|||
} d;
|
||||
|
||||
#ifndef IS_SERVER
|
||||
virtual std::shared_ptr<DrawComponent> copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const override;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
||||
|
|
|
|||
|
|
@ -61,20 +61,22 @@ void DrawTextBox::load_file(cereal::PortableBinaryInputArchive& a, VersionNumber
|
|||
}
|
||||
|
||||
#ifndef IS_SERVER
|
||||
std::shared_ptr<DrawComponent> DrawTextBox::copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawTextBox::copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawTextBox>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
a->textBox->set_rich_text_data(textBox->get_rich_text_data());
|
||||
a->init_text_box(drawP);
|
||||
return a;
|
||||
}
|
||||
|
||||
std::shared_ptr<DrawComponent> DrawTextBox::deep_copy() const {
|
||||
std::shared_ptr<DrawComponent> DrawTextBox::deep_copy(DrawingProgram& drawP) const {
|
||||
auto a = std::make_shared<DrawTextBox>();
|
||||
a->d = d;
|
||||
a->coords = coords;
|
||||
a->textBox->set_rich_text_data(textBox->get_rich_text_data());
|
||||
a->collisionTree = collisionTree;
|
||||
a->init_text_box(drawP);
|
||||
return a;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ class DrawTextBox : public DrawComponent {
|
|||
} d;
|
||||
|
||||
#ifndef IS_SERVER
|
||||
virtual std::shared_ptr<DrawComponent> copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
||||
virtual std::shared_ptr<DrawComponent> copy(DrawingProgram& drawP) const override;
|
||||
virtual std::shared_ptr<DrawComponent> deep_copy(DrawingProgram& drawP) const override;
|
||||
|
||||
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
||||
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ void DrawingProgramSelection::selection_to_clipboard() {
|
|||
});
|
||||
clipboard.components.clear();
|
||||
for(auto& c : compVecSort)
|
||||
clipboard.components.emplace_back(c->obj->deep_copy());
|
||||
clipboard.components.emplace_back(c->obj->deep_copy(drawP));
|
||||
clipboard.pos = initialSelectionAABB.center();
|
||||
clipboard.inverseScale = drawP.world.drawData.cam.c.inverseScale;
|
||||
drawP.world.rMan.copy_resource_set_to_map(resourceSet, clipboard.resources);
|
||||
|
|
@ -417,7 +417,7 @@ void DrawingProgramSelection::paste_clipboard() {
|
|||
for(auto& r : clipboard.resources)
|
||||
resourceRemapIDs[r.first] = drawP.world.rMan.add_resource(r.second);
|
||||
for(auto& c : clipboard.components)
|
||||
placedComponents.emplace_back(c->deep_copy());
|
||||
placedComponents.emplace_back(c->deep_copy(drawP));
|
||||
drawP.addToCompCacheOnInsert = false;
|
||||
auto compListInserted = drawP.components.client_insert_ordered_vector_items(allPlacement, placedComponents);
|
||||
parallel_loop_container(compListInserted, [&](auto& c) {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ MainServer::MainServer(World& initWorld, const std::string& serverLocalID):
|
|||
world(initWorld)
|
||||
{
|
||||
for(auto& c : world.drawProg.components.client_list()) {
|
||||
data.components.emplace_back(c->obj->copy());
|
||||
data.components.emplace_back(c->obj->copy(world.drawProg));
|
||||
data.components.back()->id = c->obj->id;
|
||||
data.idToComponentMap.emplace(data.components.back()->id, data.components.back());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue