| 173 | |
| 174 | |
| 175 | void JsonUiManager::executeUiUpdates(const fl::json &doc) FL_NOEXCEPT { |
| 176 | |
| 177 | if (doc.is_object()) { |
| 178 | |
| 179 | // Iterate through all keys in the JSON object |
| 180 | for (auto key : doc.keys()) { |
| 181 | const char* id_or_name = key.c_str(); |
| 182 | |
| 183 | auto component = findUiComponent(id_or_name); |
| 184 | if (component) { |
| 185 | const fl::json v = doc[key.c_str()]; |
| 186 | component->updateInternal(v); |
| 187 | } else { |
| 188 | FL_ERROR("could not find component with ID or name: " << id_or_name); |
| 189 | } |
| 190 | } |
| 191 | } else { |
| 192 | // Debug: Show what we actually received instead of just asserting |
| 193 | fl::string debugJson = doc.to_string(); |
| 194 | FL_WARN("*** UI UPDATE ERROR: Expected JSON object but got " << |
| 195 | (doc.is_array() ? "array" : "non-object") << |
| 196 | ": " << debugJson.substr(0, 200).c_str() << "..."); |
| 197 | |
| 198 | // Use a warning instead of assertion to prevent crashes |
| 199 | // FL_ASSERT(false, "JSON document is not an object, cannot execute UI updates"); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | void JsonUiManager::onEndFrame() FL_NOEXCEPT { |
| 204 | processPendingUpdates(); |