Fix Parenthesis Drag Crash - #34513
Conversation
c6c364d to
1297555
Compare
| const EngravingItem* dragElement = element; | ||
| if (element->type() == ElementType::PARENTHESIS) { | ||
| if (!score()) { | ||
| return; | ||
| } | ||
|
|
||
| muse::ContextInject<muse::ui::IUiActionsRegister> actionsRegister = { this }; | ||
| const muse::actions::ActionCode code = "add-parentheses"; | ||
| const muse::ui::UiAction& action = actionsRegister()->action(code); | ||
|
|
||
| parenthesisActionIcon = std::make_unique<ActionIcon>(score()->dummy()); | ||
| parenthesisActionIcon->setActionType(ActionIconType::PARENTHESES); | ||
| parenthesisActionIcon->setAction(code, static_cast<char16_t>(action.iconCode)); | ||
| engravingRenderer()->layoutItem(parenthesisActionIcon.get()); | ||
| dragElement = parenthesisActionIcon.get(); | ||
| } |
There was a problem hiding this comment.
This is an extremely strange place to be registering an action. It would be good to know the reasoning behind adding this block (and your changes generally) - how does it relate to the crash?
|
(I am quite busy these 2 days so I will follow-up more thoroughly later) Yes I think I did put my fix in the wrong architectural level, I will change it soon. The main problem that I am fixing is that the element dragged from stave is of wrong data type. So there needs to be a bridge to convert it to the right one Regarding other parts of this PR, I know the edits in palettecell.cpp is quite awkward. But it happens that parenthesis is a standalone data type, different from other accidentals. So the edits is simply to align the naming of the custom element created, to be Accidental instead of Action icon. I can guarantee that as of now, for this poor approach, only the edits in notation interaction.cpp is enough to prevent the crash. |
1297555 to
0b0fb8a
Compare
|
Please let me know if my latest approach looks better 🙏 |
| const String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName(); | ||
| String name = (element->isFretDiagram()) ? toFretDiagram(element.get())->harmonyPlainText() : element->translatedTypeUserName(); | ||
| if (element->isActionIcon() && toActionIcon(element.get())->actionType() == ActionIconType::PARENTHESES) { | ||
| name = TConv::capitalizedUserName(ElementType::ACCIDENTAL).translated(); |
There was a problem hiding this comment.
Please note that this part of the fix is for consistency ONLY. It is not in a right direction, in the perspective of #34514
Resolves: #32072