Fix problems with reconnects where dialog keeps popping up.

This commit is contained in:
eelke 2025-04-01 20:26:44 +02:00
parent a6be979f8e
commit 581e92723d
6 changed files with 11 additions and 10 deletions

View file

@ -247,9 +247,9 @@ void CrudModel::initRowMapping()
m_rowMapping.emplace_back(i); m_rowMapping.emplace_back(i);
} }
void CrudModel::connectionStateChanged(ASyncDBConnection::StateData state) void CrudModel::connectionStateChanged()
{ {
switch (state.State) { switch (m_dbConn.state()) {
case ASyncDBConnection::State::NotConnected: case ASyncDBConnection::State::NotConnected:
break; break;
case ASyncDBConnection::State::Connecting: case ASyncDBConnection::State::Connecting:

View file

@ -264,7 +264,7 @@ private:
private slots: private slots:
void loadIntoModel(std::shared_ptr<Pgsql::Result> data); void loadIntoModel(std::shared_ptr<Pgsql::Result> data);
void connectionStateChanged(ASyncDBConnection::StateData state); void connectionStateChanged();
}; };
#endif // CRUDMODEL_H #endif // CRUDMODEL_H

View file

@ -322,13 +322,14 @@ void QueryTool::queryTextChanged()
setQueryTextChanged(true); setQueryTextChanged(true);
} }
void QueryTool::connectionStateChanged(ASyncDBConnection::StateData state) void QueryTool::connectionStateChanged()
{ {
QString iconname; QString iconname;
switch (state.State) {
switch (m_dbConnection.state()) {
case ASyncDBConnection::State::NotConnected: case ASyncDBConnection::State::NotConnected:
QMessageBox::warning(this, "pglab", tr("Warning connection and any of its session state has been lost")); QMessageBox::warning(this, "pglab", tr("Warning connection and any of its session state has been lost"));
startConnect(); //startConnect();
iconname = "red.png"; iconname = "red.png";
break; break;
case ASyncDBConnection::State::Connecting: case ASyncDBConnection::State::Connecting:

View file

@ -113,7 +113,7 @@ private slots:
void query_ready(std::shared_ptr<Pgsql::Result>, qint64 elapsedms); void query_ready(std::shared_ptr<Pgsql::Result>, qint64 elapsedms);
void queryTextChanged(); void queryTextChanged();
void connectionStateChanged(ASyncDBConnection::StateData state); void connectionStateChanged();
void receiveNotice(Pgsql::ErrorDetails notice); void receiveNotice(Pgsql::ErrorDetails notice);
void startConnect(); void startConnect();

View file

@ -259,7 +259,7 @@ void ASyncDBConnectionThread::doStateCallback(ASyncDBConnection::StateData state
{ {
qDebug() << "State change " + state.Message; qDebug() << "State change " + state.Message;
m_state = state.State; m_state = state.State;
Q_EMIT asyncConnObject->onStateChanged(state); Q_EMIT asyncConnObject->onStateChanged();
} }
bool ASyncDBConnectionThread::waitForAndSendCommand() bool ASyncDBConnectionThread::waitForAndSendCommand()
@ -435,7 +435,7 @@ void ASyncDBConnection::doStateCallback(State state)
m_connection.setNoticeReceiver( m_connection.setNoticeReceiver(
[this](const PGresult *result) { processNotice(result); }); [this](const PGresult *result) { processNotice(result); });
} }
Q_EMIT onStateChanged(state); Q_EMIT onStateChanged();
} }

View file

@ -63,7 +63,7 @@ public:
bool cancel(); bool cancel();
Q_SIGNALS: Q_SIGNALS:
void onStateChanged(ASyncDBConnection::StateData state); void onStateChanged();
void onNotice(Pgsql::ErrorDetails notice); void onNotice(Pgsql::ErrorDetails notice);
private: private: