diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 41b91d65c3..63170fdd70 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -68,12 +68,24 @@ void PreferencesDialog::fullAvatarURLChanged(const QString& newValue, const QStr } void PreferencesDialog::accept() { + MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); + _lastGoodAvatarURL = myAvatar->getFullAvatarURLFromPreferences(); + _lastGoodAvatarName = myAvatar->getFullAvatarModelName(); savePreferences(); close(); delete _marketplaceWindow; _marketplaceWindow = NULL; } +void PreferencesDialog::restoreLastGoodAvatar() { + fullAvatarURLChanged(_lastGoodAvatarURL.toString(), _lastGoodAvatarName); +} + +void PreferencesDialog::reject() { + restoreLastGoodAvatar(); + QDialog::reject(); +} + void PreferencesDialog::openSnapshotLocationBrowser() { QString dir = QFileDialog::getExistingDirectory(this, tr("Snapshots Location"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), @@ -127,8 +139,9 @@ void PreferencesDialog::loadPreferences() { ui.collisionSoundURLEdit->setText(myAvatar->getCollisionSoundURL()); - fullAvatarURLChanged(myAvatar->getFullAvatarURLFromPreferences().toString(), - myAvatar->getFullAvatarModelName()); + _lastGoodAvatarURL = myAvatar->getFullAvatarURLFromPreferences(); + _lastGoodAvatarName = myAvatar->getFullAvatarModelName(); + fullAvatarURLChanged(_lastGoodAvatarURL.toString(), _lastGoodAvatarName); ui.sendDataCheckBox->setChecked(!menuInstance->isOptionChecked(MenuOption::DisableActivityLogger)); @@ -211,7 +224,11 @@ void PreferencesDialog::savePreferences() { } myAvatar->setCollisionSoundURL(ui.collisionSoundURLEdit->text()); - // avatar model url is already persisted by fullAvatarURLChanged() + + // MyAvatar persists its own data. If it doesn't agree with what the user has explicitly accepted, set it back to old values. + if (_lastGoodAvatarURL != myAvatar->getFullAvatarURLFromPreferences()) { + restoreLastGoodAvatar(); + } if (!Menu::getInstance()->isOptionChecked(MenuOption::DisableActivityLogger) != ui.sendDataCheckBox->isChecked()) { diff --git a/interface/src/ui/PreferencesDialog.h b/interface/src/ui/PreferencesDialog.h index 47341b8feb..6d7a87b97c 100644 --- a/interface/src/ui/PreferencesDialog.h +++ b/interface/src/ui/PreferencesDialog.h @@ -33,6 +33,9 @@ protected: private: void loadPreferences(); void savePreferences(); + QUrl _lastGoodAvatarURL; + QString _lastGoodAvatarName; + void restoreLastGoodAvatar(); Ui_PreferencesDialog ui; @@ -42,6 +45,7 @@ private: private slots: void accept(); + void reject(); void openFullAvatarModelBrowser(); void openSnapshotLocationBrowser(); void openScriptsLocationBrowser();