Skip to content

CommandQueue::referenceListViewModelInstance stores parent VMI handle on listener but registers it under the child handle #95

Open

Description

@bitfieldcore

In src/command_queue.cpp (line 326 in current HEAD on main; same code present in rive-ios 6.19.1's bundled runtime), CommandQueue::referenceListViewModelInstance looks like:

ViewModelInstanceHandle CommandQueue::referenceListViewModelInstance(
    ViewModelInstanceHandle handle,
    std::string path,
    int index,
    ViewModelInstanceListener* listener,
    uint64_t requestId)
{
    auto viewHandle = reinterpret_cast<ViewModelInstanceHandle>(
        ++m_currentViewModelHandleIdx);
    if (listener)
    {
        assert(listener->m_handle == RIVE_NULL_HANDLE);
        listener->m_handle = handle;             // parent VMI handle (input)
        listener->m_owningQueue = ref_rcp(this);
        registerListener(viewHandle, listener);  // child VMI handle (newly allocated)
    }
    ...
    return viewHandle;
}

listener->m_handle is set to handle (the parent passed in), but registerListener is keyed on viewHandle (the freshly-allocated child handle that's also the function's return value). The sibling functions in the same file — referenceNestedViewModelInstance, and both instantiateViewModelInstanceNamed overloads — set listener->m_handle = viewHandle so the two sides agree.

Is the divergence here intentional, or should line 326 also use viewHandle? Happy to send a one-line patch if it's the latter.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions