more code review response

This commit is contained in:
Seth Alves 2018-03-02 11:35:34 -08:00
parent bdd926f89e
commit 507dfa5ec3
4 changed files with 12 additions and 11 deletions

View file

@ -3109,10 +3109,7 @@ bool Application::importFromZIP(const QString& filePath) {
} }
void Application::setServerlessDomain(bool serverlessDomain) { void Application::setServerlessDomain(bool serverlessDomain) {
if (_serverlessDomain != serverlessDomain) { getEntities()->getTree()->setIsServerlessMode(serverlessDomain);
_serverlessDomain = serverlessDomain;
getEntities()->getTree()->setIsServerlessMode(_serverlessDomain);
}
} }
void Application::loadServerlessDomain(QUrl domainURL) { void Application::loadServerlessDomain(QUrl domainURL) {
@ -3136,6 +3133,8 @@ void Application::loadServerlessDomain(QUrl domainURL) {
permissions.setAll(true); permissions.setAll(true);
DependencyManager::get<NodeList>()->setPermissions(permissions); DependencyManager::get<NodeList>()->setPermissions(permissions);
// we can't import directly into the main tree because we would need to lock it, and
// Octree::readFromURL calls loop.exec which can run code which will also attempt to lock the tree.
EntityTreePointer tmpTree(new EntityTree()); EntityTreePointer tmpTree(new EntityTree());
tmpTree->setIsServerlessMode(true); tmpTree->setIsServerlessMode(true);
tmpTree->createRootElement(); tmpTree->createRootElement();

View file

@ -286,7 +286,7 @@ public:
bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; } bool getSaveAvatarOverrideUrl() { return _saveAvatarOverrideUrl; }
void saveNextPhysicsStats(QString filename); void saveNextPhysicsStats(QString filename);
bool isServerlessMode() const { return _serverlessDomain; } bool isServerlessMode() const { return getEntities()->getTree()->isServerlessMode(); }
void replaceDomainContent(const QString& url); void replaceDomainContent(const QString& url);
@ -720,7 +720,5 @@ private:
std::atomic<bool> _pendingIdleEvent { true }; std::atomic<bool> _pendingIdleEvent { true };
std::atomic<bool> _pendingRenderEvent { true }; std::atomic<bool> _pendingRenderEvent { true };
bool _serverlessDomain { true };
}; };
#endif // hifi_Application_h #endif // hifi_Application_h

View file

@ -221,10 +221,12 @@ void Avatar::updateAvatarEntities() {
return; return;
} }
if (getID() == QUuid() || if (getID().isNull() ||
getID() == AVATAR_SELF_ID || getID() == AVATAR_SELF_ID ||
DependencyManager::get<NodeList>()->getSessionUUID() == QUuid()) { DependencyManager::get<NodeList>()->getSessionUUID() == QUuid()) {
return; // wait until MyAvatar and this Node gets an ID before doing this. // wait until MyAvatar and this Node gets an ID before doing this. Otherwise, various things go wrong --
// things get their parent fixed up from AVATAR_SELF_ID to a null uuid which means "no parent".
return;
} }
auto treeRenderer = DependencyManager::get<EntityTreeRenderer>(); auto treeRenderer = DependencyManager::get<EntityTreeRenderer>();

View file

@ -303,8 +303,10 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
bool isPossiblePlaceName(QString possiblePlaceName) { bool isPossiblePlaceName(QString possiblePlaceName) {
bool result { false }; bool result { false };
int len = possiblePlaceName.length(); int length = possiblePlaceName.length();
if (possiblePlaceName != "localhost" && len >= 4 && len <= 64) { static const int MINIMUM_PLACENAME_LENGTH = 4;
static const int MAXIMUM_PLACENAME_LENGTH = 64;
if (possiblePlaceName != "localhost" && length >= MINIMUM_PLACENAME_LENGTH && length <= MAXIMUM_PLACENAME_LENGTH) {
const QRegExp PLACE_NAME_REGEX = QRegExp("^[0-9A-Za-z](([0-9A-Za-z]|-(?!-))*[^\\W_]$|$)"); const QRegExp PLACE_NAME_REGEX = QRegExp("^[0-9A-Za-z](([0-9A-Za-z]|-(?!-))*[^\\W_]$|$)");
result = PLACE_NAME_REGEX.indexIn(possiblePlaceName) == 0; result = PLACE_NAME_REGEX.indexIn(possiblePlaceName) == 0;
} }