diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-17 13:55:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-17 13:55:59 +0300 |
commit | 89dd7d47dabcc52a56a89d9ac5246582fa1b138c (patch) | |
tree | c795eb2a2c218029de17e0ca40ea8b6d00dc3c81 /src | |
parent | 420c7c31f6ac97741feaf9f34e641ec0d6e0fdf5 (diff) | |
download | manaplus-89dd7d47dabcc52a56a89d9ac5246582fa1b138c.tar.gz manaplus-89dd7d47dabcc52a56a89d9ac5246582fa1b138c.tar.bz2 manaplus-89dd7d47dabcc52a56a89d9ac5246582fa1b138c.tar.xz manaplus-89dd7d47dabcc52a56a89d9ac5246582fa1b138c.zip |
Add missing checks into logindialog and xml.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/windows/logindialog.cpp | 14 | ||||
-rw-r--r-- | src/utils/xml.cpp | 15 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 47e86471e..93bf10bc3 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -94,7 +94,8 @@ LoginDialog::LoginDialog(LoginData &data, setCloseButton(true); setWindowName("Login"); - charServerHandler->clear(); + if (charServerHandler) + charServerHandler->clear(); // TRANSLATORS: login dialog label Label *const serverLabel1 = new Label(this, _("Server:")); @@ -191,8 +192,15 @@ void LoginDialog::postInit() mPassField->requestFocus(); mLoginButton->setEnabled(canSubmit()); - mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled() - || !mLoginData->registerUrl.empty()); + if (loginHandler) + { + mRegisterButton->setEnabled(loginHandler->isRegistrationEnabled() + || !mLoginData->registerUrl.empty()); + } + else + { + mRegisterButton->setEnabled(false); + } } LoginDialog::~LoginDialog() diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp index cb0cc56b8..8642140c9 100644 --- a/src/utils/xml.cpp +++ b/src/utils/xml.cpp @@ -104,11 +104,16 @@ namespace XML // Get length of file file.seekg(0, std::ios::end); size = static_cast<int>(file.tellg()); - file.seekg(0, std::ios::beg); - - data = static_cast<char*>(malloc(size)); - - file.read(data, size); + if (size < 0) + { + logger->log("Error loading XML file %s", filename.c_str()); + } + else + { + file.seekg(0, std::ios::beg); + data = static_cast<char*>(malloc(size)); + file.read(data, size); + } file.close(); } else |