Skip to content

Rawpointer removal#169

Open
suamor wants to merge 4 commits into
mainfrom
rawpointer-removal
Open

Rawpointer removal#169
suamor wants to merge 4 commits into
mainfrom
rawpointer-removal

Conversation

@suamor

@suamor suamor commented May 17, 2020

Copy link
Copy Markdown
Collaborator

Part 3: Rework of MusElement classes (unfinished)

suamor added 3 commits May 13, 2020 23:32
- 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 itsgeorg and matevz May 17, 2020 10:58
Comment thread src/control/helpctl.cpp
browser = std::make_unique<CAHelpBrowser>();
browser->setAttribute(Qt::WA_DeleteOnClose);
} else if (dynamic_cast<CAMainWin*>(helpWidget)) {
browser = static_cast<CAMainWin*>(helpWidget)->helpWidget();

Copy link
Copy Markdown
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?

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
Copy Markdown
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
Copy Markdown
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.


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

Copy link
Copy Markdown
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.

2 participants