Repository: FreeCAD/FreeCAD
File: src/Gui/Selection/Selection.cpp (C++)

Code before:
    return temp;
}

bool SelectionSingleton::needPickedList() const
{
    return _needPickedList;
}

void SelectionSingleton::enablePickedList(bool enable)
{
    if(enable != _needPickedList) {
        _needPickedList = enable;
        _PickedList.clear();
        notify(SelectionChanges(SelectionChanges::PickedListChanged));
    }
}

static void notifyDocumentObjectViewProvider(const SelectionChanges& changes) {
    const auto* doc = App::GetApplication().getDocument(changes.pDocName);
    if (!doc) return;

    const auto* obj = doc->getObject(changes.pObjectName);
    if (!obj) return;

    auto* vp = Application::Instance->getViewProvider(obj);
    if (!vp) return;

    vp->onSelectionChanged(changes);
}

void SelectionSingleton::notify(SelectionChanges &&Chng)
{
    if(Notifying) {
        NotificationQueue.push_back(std::move(Chng));
        return;
    }
    Base::FlagToggler<bool> flag(Notifying);
    NotificationQueue.push_back(std::move(Chng));
    while(!NotificationQueue.empty()) {
        const auto &msg = NotificationQueue.front();
        bool notify;
        switch(msg.Type) {
        case SelectionChanges::AddSelection:
            notify = isSelected(msg.pDocName, msg.pObjectName, msg.pSubName, ResolveMode::NoResolve);
            break;
        case SelectionChanges::RmvSelection:
            notify = !isSelected(msg.pDocName, msg.pObjectName, msg.pSubName, ResolveMode::NoResolve);
            break;
        case SelectionChanges::SetPreselect:
            notify = CurrentPreselection.Type==SelectionChanges::SetPreselect
                && CurrentPreselection.Object == msg.Object;

Review comment (suggestion):
```suggestion
    if (!vp) {
        return;
    }
```

Code after:
    return temp;
}

bool SelectionSingleton::needPickedList() const
{
    return _needPickedList;
}

void SelectionSingleton::enablePickedList(bool enable)
{
    if(enable != _needPickedList) {
        _needPickedList = enable;
        _PickedList.clear();
        notify(SelectionChanges(SelectionChanges::PickedListChanged));
    }
}

static void notifyDocumentObjectViewProvider(const SelectionChanges& changes) {
    const auto* doc = App::GetApplication().getDocument(changes.pDocName);
    if (!doc) {
        return;
    }

    const auto* obj = doc->getObject(changes.pObjectName);
    if (!obj) {
        return;
    }

    auto* vp = Application::Instance->getViewProvider(obj);
    if (!vp) {
        return;
    }

    vp->onSelectionChanged(changes);
}

void SelectionSingleton::notify(SelectionChanges &&Chng)
{
    if(Notifying) {
        NotificationQueue.push_back(std::move(Chng));
        return;
    }
    Base::FlagToggler<bool> flag(Notifying);
    NotificationQueue.push_back(std::move(Chng));
    while(!NotificationQueue.empty()) {
        const auto &msg = NotificationQueue.front();
        bool notify = false;
        switch(msg.Type) {
        case SelectionChanges::AddSelection:
            notify = isSelected(msg.pDocName, msg.pObjectName, msg.pSubName, ResolveMode::NoResolve);
            break;