-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing sprites when using Element::Clone #191
Comments
Does this only occur during drag cloning? Let me know if that fixes it. We might also want to always reload the texture when attaching |
I was manually calling Element::Clone in my application |
Hm, that seemed to work fine when I tested it? Does removing the |
Nope that did not fix it |
This is the code I'm using, to essentially duplicate an element: auto ptr = document->GetElementById("list-selection");
listSelection = document->AppendChild(ptr->Clone()); |
Hm, strange, that is working well for me. Here is the full example: static const String document_img_rml = R"(
<rml>
<head>
<title>Test</title>
<link type="text/rcss" href="/assets/rml.rcss"/>
<link type="text/rcss" href="/assets/invader.rcss"/>
<style>
body
{
left: 0;
top: 0;
right: 0;
bottom: 0;
}
</style>
</head>
<body>
<img sprite="icon-invader"/>
</body>
</rml>
)";
TEST_CASE("Element.clone")
{
Context* context = TestsShell::GetContext();
REQUIRE(context);
ElementDocument* document = context->LoadDocumentFromMemory(document_img_rml);
REQUIRE(document);
document->Show();
context->Update();
context->Render();
Element* element = document->GetChild(0);
REQUIRE(element);
REQUIRE(element->GetTagName() == "img");
document->AppendChild(element->Clone());
TestsShell::RenderLoop();
document->Close();
TestsShell::ShutdownShell();
} This renders two images side by side. |
does it play a role that the element i require was inside a template included into the document maybe? |
I'm not sure why that would be a problem, but it would be something to investigate. |
@Dakror Did you ever figure this out? |
I actually haven't continued to investigate it, busy with other things. |
Closing this for now due to inactivity and inability to reproduce. Please do re-open if further investigations show issues in the library. |
Since Clone creates a detached copy, Elements like ElementImage fail when looking up sprites that were registered in the stylesheet of the owner document.
Is there another way to currently duplicate an Element inside the same owner document or refresh the image after the fact? If not, it might be worth to add a
clone->SetOwnerDocument(GetOwnerDocument());
inside Element::CloneThe text was updated successfully, but these errors were encountered: