if the hostname field is left blank reset to DEFAULT_DOMAIN_HOSTNAME

This commit is contained in:
Stephen Birarda 2013-07-18 17:42:25 -07:00
parent 01e6891fd3
commit ef7dc4a39a
2 changed files with 19 additions and 6 deletions

View file

@ -1151,11 +1151,18 @@ void Application::editPreferences() {
return;
}
char newHostname[MAX_HOSTNAME_BYTES] = {};
memcpy(newHostname, domainServerHostname->text().toAscii().data(), domainServerHostname->text().size());
QByteArray newHostname;
if (domainServerHostname->text().size() > 0) {
// the user input a new hostname, use that
newHostname = domainServerHostname->text().toAscii();
} else {
// the user left the field blank, use the default hostname
newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
}
// check if the domain server hostname is new
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname, strlen(newHostname)) != 0) {
if (memcmp(NodeList::getInstance()->getDomainHostname(), newHostname.constData(), newHostname.size()) != 0) {
NodeList::getInstance()->clear();
@ -1165,7 +1172,8 @@ void Application::editPreferences() {
// reset the environment to default
_environment.resetToDefault();
NodeList::getInstance()->setDomainHostname(newHostname);
// set the new hostname
NodeList::getInstance()->setDomainHostname(newHostname.constData());
}
QUrl url(avatarURL->text());

View file

@ -519,12 +519,17 @@ void NodeList::loadData(QSettings *settings) {
}
void NodeList::saveData(QSettings* settings) {
settings->beginGroup(DOMAIN_SERVER_SETTING_KEY);
if (memcmp(_domainHostname, DEFAULT_DOMAIN_HOSTNAME, strlen(DEFAULT_DOMAIN_HOSTNAME)) != 0) {
// the user is using a different hostname, store it
settings->beginGroup(DOMAIN_SERVER_SETTING_KEY);
settings->setValue(DOMAIN_SERVER_SETTING_KEY, QVariant(_domainHostname));
settings->endGroup();
} else {
// the user has switched back to default, remove the current setting
settings->remove(DOMAIN_SERVER_SETTING_KEY);
}
settings->endGroup();
}
NodeList::iterator NodeList::begin() const {