The EntityTree needs to be references by a shared_ptr somewhere. The EntityTree does not start with a root element by default, which some operations rely on to work as expected.
Showing the changes to interface/src/Application.cpp (1 of 1 file). Show all
Unified · Split
| @@ -2337,7 +2337,8 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 2336 unmodified lines | ||
| 2337 | 2337 | QVector<EntityItemPointer> entities; |
| 2338 | 2338 | |
| 2339 | 2339 | auto entityTree = _entities.getTree(); |
| 2340 | − EntityTree exportTree; | |
| 2340 | + auto exportTree = std::make_shared<EntityTree>(); | |
| 2341 | + exportTree->createRootElement(); | |
| 2341 | 2342 | |
| 2342 | 2343 | glm::vec3 root(TREE_SCALE, TREE_SCALE, TREE_SCALE); |
| 2343 | 2344 | for (auto entityID : entityIDs) { |
| @@ -2364,10 +2365,10 @@ bool Application::exportEntities(const QString& filename, const QVector<EntityIt · 20 unmodified lines | ||
| 2364 | 2365 | auto properties = entityItem->getProperties(); |
| 2365 | 2366 | |
| 2366 | 2367 | properties.setPosition(properties.getPosition() - root); |
| 2367 | − exportTree.addEntity(entityItem->getEntityItemID(), properties); | |
| 2368 | + exportTree->addEntity(entityItem->getEntityItemID(), properties); | |
| 2368 | 2369 | } |
| 2369 | 2370 | |
| 2370 | − exportTree.writeToJSONFile(filename.toLocal8Bit().constData()); | |
| 2371 | + exportTree->writeToJSONFile(filename.toLocal8Bit().constData()); | |
| 2371 | 2372 | |
| 2372 | 2373 | // restore the main window's active state |
| 2373 | 2374 | _window->activateWindow(); |
| @@ -2380,15 +2381,16 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa · 6 unmodified lines | ||
| 2380 | 2381 | |
| 2381 | 2382 | if (entities.size() > 0) { |
| 2382 | 2383 | glm::vec3 root(x, y, z); |
| 2383 | − EntityTree exportTree; | |
| 2384 | + auto exportTree = std::make_shared<EntityTree>(); | |
| 2385 | + exportTree->createRootElement(); | |
| 2384 | 2386 | |
| 2385 | 2387 | for (int i = 0; i < entities.size(); i++) { |
| 2386 | 2388 | EntityItemProperties properties = entities.at(i)->getProperties(); |
| 2387 | 2389 | EntityItemID id = entities.at(i)->getEntityItemID(); |
| 2388 | 2390 | properties.setPosition(properties.getPosition() - root); |
| 2389 | − exportTree.addEntity(id, properties); | |
| 2391 | + exportTree->addEntity(id, properties); | |
| 2390 | 2392 | } |
| 2391 | − exportTree.writeToSVOFile(filename.toLocal8Bit().constData()); | |
| 2393 | + exportTree->writeToSVOFile(filename.toLocal8Bit().constData()); | |
| 2392 | 2394 | } else { |
| 2393 | 2395 | qCDebug(interfaceapp) << "No models were selected"; |
| 2394 | 2396 | return false; |