Make IOManager a singleton
MODIFY
src/io/iomanager.h
src/io/iomanager.h
@@ -20,7 +20,11 @@ class IOManager : public QObject {
Q_OBJECT
public:
- IOManager();
+ static IOManager& get() {
+ static IOManager manager;
+ return manager;
+ }
+
IOBase* createPeripheral(IOType type);
void removePeripheral(IOBase* peripheral, std::atomic<bool>& ok);
const MemoryMap& memoryMap() const { return m_memoryMap; }
@@ -43,6 +47,7 @@ signals:
void peripheralRemoved(QObject* peripheral);
private:
+ IOManager();
std::map<QString, uint32_t> assemblerSymbolsForPeriph(IOBase* peripheral) const;
/**

MODIFY
src/iotab.cpp
src/iotab.cpp
@@ -61,10 +61,10 @@ IOTab::IOTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_
}
});
- connect(&m_iomanager, &IOManager::peripheralRemoved, this, &IOTab::removePeripheral);
+ connect(&IOManager::get(), &IOManager::peripheralRemoved, this, &IOTab::removePeripheral);
connect(m_ui->peripheralsTab, &QTabWidget::currentChanged, this, &IOTab::setPeripheralMDIWindowActive);
- m_ui->memoryMapView->setModel(new MemoryMapModel(&m_iomanager, this));
+ m_ui->memoryMapView->setModel(new MemoryMapModel(&IOManager::get(), this));
m_ui->memoryMapView->horizontalHeader()->setSectionResizeMode(MemoryMapModel::Name, QHeaderView::ResizeToContents);
m_ui->memoryMapView->horizontalHeader()->setSectionResizeMode(MemoryMapModel::AddressRange,
QHeaderView::ResizeToContents);
@@ -72,7 +72,7 @@ IOTab::IOTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_
}
void IOTab::createPeripheral(IOType type) {
- auto* peripheral = m_iomanager.createPeripheral(type);
+ auto* peripheral = IOManager::get().createPeripheral(type);
// Create tab for peripheral
auto* peripheralTab = new IOPeripheralTab(this, peripheral);
m_ui->peripheralsTab->addTab(peripheralTab, peripheral->name());

MODIFY
src/iotab.h
src/iotab.h
@@ -55,6 +55,5 @@ private:
* Pointer from the tab associated with a peripheral to its corresponding MDI subwindow.
*/
std::unordered_map<QWidget*, QMdiSubWindow*> m_subWindows;
- IOManager m_iomanager;
};
} // namespace Ripes

Make IOManager a singleton