Made step to remove ASyncWindow in favour of usage of Future and FutureWatcher.
This should allow concurrency in the plugins to be independent from their container. Contains also some work on the system for registering plugins.
This commit is contained in:
parent
a54a063c13
commit
15bee33076
25 changed files with 327 additions and 52 deletions
|
|
@ -15,7 +15,7 @@
|
|||
#include <QMetaMethod>
|
||||
#include "QueryTab.h"
|
||||
#include "util.h"
|
||||
#include "PluginContentWidget.h"
|
||||
#include "plugin_support/PluginContentWidget.h"
|
||||
#include "CodeGenerator.h"
|
||||
#include "MasterController.h"
|
||||
#include "CrudTab.h"
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
#include "ScopeGuard.h"
|
||||
#include "EditTableWidget.h"
|
||||
#include "IPluginContentWidgetContext.h"
|
||||
#include "TaskExecutor.h"
|
||||
|
||||
namespace pg = Pgsql;
|
||||
|
||||
|
|
@ -49,9 +50,9 @@ namespace DatabaseWindow_details {
|
|||
return m_window->getDatabase();
|
||||
}
|
||||
|
||||
void QueueTask(TSQueue::t_Callable c) override
|
||||
void QueueTask(TSQueue::t_Callable ) override
|
||||
{
|
||||
m_window->QueueTask(c);
|
||||
// m_window->QueueTask(c);
|
||||
}
|
||||
|
||||
void showStatusMessage(const QString &msg) override
|
||||
|
|
@ -67,18 +68,20 @@ using namespace DatabaseWindow_details;
|
|||
|
||||
|
||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||
: ASyncWindow(parent)
|
||||
: QMainWindow(parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
, m_context(new DatabaseWindowContentContext(this))
|
||||
, m_masterController(master)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setDocumentMode(true);
|
||||
|
||||
connect(&loadWatcher, &QFutureWatcher<LoadCatalog::Result>::finished,
|
||||
this, &DatabaseWindow::catalogLoaded);
|
||||
}
|
||||
|
||||
DatabaseWindow::~DatabaseWindow()
|
||||
{
|
||||
loader.reset();
|
||||
delete m_context;
|
||||
delete ui;
|
||||
}
|
||||
|
|
@ -128,10 +131,9 @@ void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
|||
title += m_config.name().c_str();
|
||||
setWindowTitle(title);
|
||||
|
||||
loader = std::make_shared<QLoad>(m_config, [this](QRunnable *) {
|
||||
QueueTask([this] () { catalogLoaded(); });
|
||||
} );
|
||||
WorkManager::getWorkManager()->addRunnable(loader.get());
|
||||
auto f = TaskExecutor::run(new LoadCatalog(m_config));
|
||||
loadWatcher.setFuture(f);
|
||||
|
||||
} catch (std::runtime_error &ex) {
|
||||
QMessageBox::critical(this, "Error reading database",
|
||||
QString::fromUtf8(ex.what()));
|
||||
|
|
@ -143,8 +145,8 @@ void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
|||
void DatabaseWindow::catalogLoaded()
|
||||
{
|
||||
try {
|
||||
SCOPE_EXIT { loader.reset(); };
|
||||
m_database = loader->GetResult();
|
||||
//SCOPE_EXIT { loadFuture = {}; };
|
||||
m_database = loadWatcher.future().result();
|
||||
|
||||
auto tt = new TablesPage(this);
|
||||
tt->setCatalog(m_database->catalog());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue