fix error popup when sql is disabled

This commit is contained in:
T1ti
2023-07-16 00:23:35 +02:00
parent e5d5127eff
commit 7358075d3e
2 changed files with 10 additions and 3 deletions

View File

@@ -81,8 +81,10 @@ namespace mysql
{
prompt.setIcon(QMessageBox::Warning);
prompt.setText("Failed to load MySQL database, check your settings.");
prompt.setText("Failed to load MySQL database, check your settings. \nIf you did not intend to use this feature, disable it in Noggit->settings->MySQL");
prompt.setWindowTitle("Noggit Database Error");
// disable if connection is not valid
// settings.value("project/mysql/enabled") = false;
std::stringstream promptText;
promptText << "\n# ERR: " << e.what();

View File

@@ -126,12 +126,17 @@ namespace Noggit::Ui::Windows
#ifdef USE_MYSQL_UID_STORAGE
bool use_mysql = settings.value("project/mysql/enabled", false).toBool();
mysql::testConnection(true);
bool valid_conn = false;
if (use_mysql)
{
valid_conn = mysql::testConnection(true);
}
if ((use_mysql && mysql::hasMaxUIDStoredDB(_world->getMapID()))
if ((valid_conn && mysql::hasMaxUIDStoredDB(_world->getMapID()))
|| uid_storage::hasMaxUIDStored(_world->getMapID())
)
{
_world->mapIndex.loadMaxUID();
enterMapAt(pos, camera_pitch, camera_yaw, uid_fix_mode::none, from_bookmark);
}