Skip to content
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

Rawpointer removal #169

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Rawpointer removal #169

wants to merge 4 commits into from

Conversation

suamor
Copy link
Collaborator

@suamor suamor commented May 17, 2020

Part 3: Rework of MusElement classes (unfinished)

- Replace Raw Pointer with Smart Pointers
- Change API for mainwinprogressctl (less likely to crash)
- Move importFile pointer (as member)
- Resource handling uses shared pointer
- Multiple raw pointers are unique pointer
- Adapted interfaces
- Finish pointer replacement of control
- Replace pointers for all MusElements (score)
- Adapt some interfaces to avoid loss of shared pointers
- Attention: Fixes some crashes but introduces new ones
@suamor suamor requested review from matevz and itsgeorg May 17, 2020 10:58
browser->setAttribute(Qt::WA_DeleteOnClose);
} else if (dynamic_cast<CAMainWin*>(helpWidget)) {
browser = static_cast<CAMainWin*>(helpWidget)->helpWidget();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use smart pointet for helpWidget too?

@@ -31,7 +31,7 @@
(eg. audio file of a theme), staff (eg. svg images in contemporary music),
voice etc.
You can simply add a resource by calling
CADocument::addResource( new CAResource( "/home/user/title.jpeg", "My image") );
CADocument::addResource( make_shared<CAResource>( "/home/user/title.jpeg", "My image") );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::make_shared

mpoMusElement = new CAClef(_eClef, staff, 0, _iClefOffset);
success = staff->voiceList()[0]->insert(right, mpoMusElement);
mpoMusElement = std::make_shared<CAClef>(_eClef, staff, 0, _iClefOffset);
success = staff->voiceList()[0]->insert(right, mpoMusElement.get());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to QList<CAMusElement*>? Should it become QList<std::shared_ptr>? If so, we need to update swig helpers which transform QList<CAMusElement*> type to native python lists.

@@ -459,7 +459,7 @@ bool CAMusElementFactory::configureMark(CAMusElement* elt)
}

if (success) {
elt->addMark(static_cast<CAMark*>(mpoMusElement));
elt->addMark(static_cast<CAMark*>(mpoMusElement.get()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should addMark() accept smart pointer as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants