这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Fix property GUI updates by using ClientConnectionModel callbacks

Problem

The GUI property updates were not working for SetPropertyDataReply messages because InitiatorWidget::setupPropertyCallbacks() was bypassing the ClientConnectionModel callback system and registering directly with ObservablePropertyList. This meant that while the callback was invoked, it didn't trigger the proper GUI update chain.

Solution

Replaced direct ObservablePropertyList callbacks with ClientConnectionModel callbacks in InitiatorWidget to mirror the Kotlin implementation pattern:

Before (bypassing ClientConnectionModel):

observable_properties->addPropertyUpdatedCallback([this](const std::string& propertyId) {
    QMetaObject::invokeMethod(this, [this]() {
        updatePropertyList();
    }, Qt::QueuedConnection);
});

After (using ClientConnectionModel callbacks):

connection->add_properties_changed_callback([this]() {
    QMetaObject::invokeMethod(this, [this]() {
        updatePropertyList();
    }, Qt::QueuedConnection);
});

Key Insights from Kotlin Implementation

  • Kotlin uses mutableStateListOf<PropertyValue>() for automatic Compose UI updates
  • The critical callback conn.propertyClient.properties.valueUpdated.add { entry -> directly modifies the reactive state list
  • Composable ClientPropertyList tracks vm.conn.properties directly for reactive updates
  • Property details view uses vm.conn.properties.firstOrNull { it.id == propertyId } for reactive binding

The C++ version now replicates this reactive pattern by ensuring ClientConnectionModel callbacks properly trigger Qt widget updates.

Changes Made

  • Modified InitiatorWidget::setupPropertyCallbacks() to use ClientConnectionModel callback system
  • Removed direct ObservablePropertyList callback registration (19 lines removed, 5 lines added)
  • Follows the same event dispatching chain as the Kotlin implementation
  • Ensures SetPropertyDataReply messages trigger GUI updates via the proper callback chain

Testing

  • ✅ Build completed successfully with no errors
  • ✅ No other Qt widgets use the problematic direct callback pattern
  • ✅ ClientConnectionModel.cpp properly calls registered callbacks in on_property_value_updated()
  • ⚠️ GUI testing requires display environment (cannot test in headless environment)

Verification Steps

  1. Build the application: cmake -B build && cmake --build build
  2. Run the GUI application: ./build/tools/qt5-ci-tool/midicci-gui
  3. Trigger property value updates (SetPropertyDataReply messages)
  4. Verify that property values are displayed in the GUI interface
  5. Confirm that property list updates correctly when properties change

Link to Devin run: https://app.devin.ai/sessions/69f0e6db929942fd921006ff78d5c946
Requested by: Atsushi Eno (atsushieno@gmail.com)

- Replace direct ObservablePropertyList callbacks with ClientConnectionModel callbacks in InitiatorWidget
- Follow Kotlin implementation pattern where mutableStateListOf automatically triggers UI updates
- Ensures SetPropertyDataReply messages properly trigger GUI updates via callback chain
- Mirrors Kotlin's conn.propertyClient.properties.valueUpdated.add callback mechanism

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Add registerPropertyValueCallbacks() to register ClientConnectionModel callbacks when connections change
- Add updatePropertyValueDisplay() to update value editor and labels when property values change
- Register callbacks for each property item to trigger GUI updates on SetPropertyDataReply
- Follow Kotlin implementation pattern of registering callbacks on property value updates
- Update value text editor and display labels in readonly mode
- Replace setupPropertyCallbacks() with new callback registration approach

Co-Authored-By: Atsushi Eno <atsushieno@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@atsushieno atsushieno closed this Jun 21, 2025
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