Completed removal of ASyncWindow

This commit is contained in:
eelke 2018-12-31 09:40:25 +01:00
parent 424fb5984d
commit cc4f309c0f
7 changed files with 3 additions and 56 deletions

View file

@ -1,25 +0,0 @@
#include "ASyncWindow.h"
#include <QTimer>
ASyncWindow::ASyncWindow(QWidget *parent)
: QMainWindow(parent)
{}
void ASyncWindow::QueueTask(TSQueue::t_Callable c)
{
m_taskQueue.add(std::move(c));
// Theoretically this needs to be only called if the queue was empty because otherwise it already would
// be busy emptying the queue. For now however I think it is safer to call it just to make sure.
QMetaObject::invokeMethod(this, "processCallableQueue", Qt::QueuedConnection); // queues on main thread
}
void ASyncWindow::processCallableQueue()
{
if (!m_taskQueue.empty()) {
auto c = m_taskQueue.pop();
c();
if (!m_taskQueue.empty()) {
QTimer::singleShot(0, this, SLOT(processCallableQueue()));
}
}
}

View file

@ -1,24 +0,0 @@
#ifndef ASYNCWINDOW_H
#define ASYNCWINDOW_H
#include <QMainWindow>
#include "tsqueue.h"
class ASyncWindow : public QMainWindow {
Q_OBJECT
public:
ASyncWindow(QWidget *parent);
/* Meant to be called from other threads to pass a code block
* that has to be executed in the context of the thread of the window.
*/
void QueueTask(TSQueue::t_Callable c);
private:
TSQueue m_taskQueue;
private slots:
void processCallableQueue();
};
#endif // ASYNCWINDOW_H

View file

@ -1,5 +1,4 @@
#include "CrudModel.h" #include "CrudModel.h"
#include "ASyncWindow.h"
#include "OpenDatabase.h" #include "OpenDatabase.h"
#include "catalog/PgDatabaseCatalog.h" #include "catalog/PgDatabaseCatalog.h"
#include "catalog/PgAttribute.h" #include "catalog/PgAttribute.h"

View file

@ -5,7 +5,6 @@
#include "ConnectionConfig.h" #include "ConnectionConfig.h"
#include "OpenDatabase.h" #include "OpenDatabase.h"
#include <QLabel> #include <QLabel>
//#include "ASyncWindow.h"
#include <QLabel> #include <QLabel>
#include <QRunnable> #include <QRunnable>
#include <QSocketNotifier> #include <QSocketNotifier>

View file

@ -6,7 +6,7 @@
#include "catalog/PgDatabaseCatalog.h" #include "catalog/PgDatabaseCatalog.h"
ServerWindow::ServerWindow(MasterController *master, QWidget *parent) ServerWindow::ServerWindow(MasterController *master, QWidget *parent)
: ASyncWindow(parent) : QMainWindow(parent)
, ui(new Ui::ServerWindow) , ui(new Ui::ServerWindow)
, m_masterController(master) , m_masterController(master)
{ {

View file

@ -1,8 +1,8 @@
#ifndef SERVERWINDOW_H #ifndef SERVERWINDOW_H
#define SERVERWINDOW_H #define SERVERWINDOW_H
#include "ASyncWindow.h"
#include "ConnectionConfig.h" #include "ConnectionConfig.h"
#include <QMainWindow>
#include <memory> #include <memory>
namespace Ui { namespace Ui {
@ -14,7 +14,7 @@ class OpenDatabase;
class DatabasesTableModel; class DatabasesTableModel;
class RolesTableModel; class RolesTableModel;
class ServerWindow : public ASyncWindow { class ServerWindow : public QMainWindow {
Q_OBJECT Q_OBJECT
public: public:
explicit ServerWindow(MasterController *master, QWidget *parent ); explicit ServerWindow(MasterController *master, QWidget *parent );

View file

@ -42,7 +42,6 @@ SOURCES += main.cpp\
OpenDatabase.cpp \ OpenDatabase.cpp \
SqlSyntaxHighlighter.cpp \ SqlSyntaxHighlighter.cpp \
ServerWindow.cpp \ ServerWindow.cpp \
ASyncWindow.cpp \
DatabasesTableModel.cpp \ DatabasesTableModel.cpp \
RolesTableModel.cpp \ RolesTableModel.cpp \
ConnectionList.cpp \ ConnectionList.cpp \
@ -107,7 +106,6 @@ HEADERS += \
OpenDatabase.h \ OpenDatabase.h \
SqlSyntaxHighlighter.h \ SqlSyntaxHighlighter.h \
ServerWindow.h \ ServerWindow.h \
ASyncWindow.h \
DatabasesTableModel.h \ DatabasesTableModel.h \
RolesTableModel.h \ RolesTableModel.h \
ConnectionList.h \ ConnectionList.h \