The MainWindow now uses a background task to load the catalog.
As the background task can't be cancelled yet only closing of the window can block if the task is still running.
This commit is contained in:
parent
057e745ebe
commit
2705a3417b
4 changed files with 173 additions and 64 deletions
|
|
@ -6,14 +6,20 @@
|
|||
#include "OpenDatabase.h"
|
||||
#include <QLabel>
|
||||
#include "ASyncWindow.h"
|
||||
#include <QLabel>
|
||||
#include <QRunnable>
|
||||
#include <QSocketNotifier>
|
||||
#include <memory>
|
||||
#include <future>
|
||||
#include "Pgsql_Connection.h"
|
||||
#include "QueuedBackgroundTask.h"
|
||||
#include <chrono>
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
|
@ -45,18 +51,33 @@ private:
|
|||
|
||||
MasterController *m_masterController;
|
||||
|
||||
// class OpenDocumentController {
|
||||
// public:
|
||||
class QLoad : public QueuedBackgroundTask {
|
||||
public:
|
||||
explicit QLoad(ConnectionConfig config, CompletionFunction on_completion)
|
||||
: QueuedBackgroundTask(on_completion)
|
||||
, m_config(config)
|
||||
{}
|
||||
|
||||
// private:
|
||||
OpenDatabase::OpenDatabaseSPtr GetResult()
|
||||
{
|
||||
if (hasException()) rethrow();
|
||||
return result;
|
||||
}
|
||||
protected:
|
||||
|
||||
// QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
// QDir dir(path);
|
||||
// if (!dir.exists()) {
|
||||
// dir.mkpath(".");
|
||||
// }
|
||||
OpenDatabase::OpenDatabaseSPtr result;
|
||||
virtual void doRun()
|
||||
{
|
||||
auto res = OpenDatabase::createOpenDatabase(m_config);
|
||||
result = res.get();
|
||||
}
|
||||
private:
|
||||
|
||||
ConnectionConfig m_config;
|
||||
};
|
||||
|
||||
std::shared_ptr<QLoad> loader;
|
||||
|
||||
// };
|
||||
|
||||
QueryTab *GetActiveQueryTab();
|
||||
|
||||
|
|
@ -64,7 +85,7 @@ private:
|
|||
void showEvent(QShowEvent *event);
|
||||
QueryTab *newSqlPage();
|
||||
|
||||
void catalogLoaded(Expected<OpenDatabase::OpenDatabaseSPtr> result);
|
||||
void catalogLoaded();
|
||||
|
||||
private slots:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue