Browse Source

Assorted fixes

* Fix for wrong QSharedPointer usage
* Catch exceptions from Daemon
pull/79/head
nonlin-lin-chaos-order-etc-etal 2 years ago
parent
commit
7d70ace5a2
  1. 18
      src/DaemonQT.cpp
  2. 2
      src/SaverImpl.cpp
  3. 7
      src/SaverImpl.h
  4. 4
      src/mainwindow.cpp

18
src/DaemonQT.cpp

@ -25,40 +25,40 @@ namespace qt @@ -25,40 +25,40 @@ namespace qt
void Worker::startDaemon()
{
qDebug("Performing daemon start...");
//try{
try{
m_Daemon.start();
qDebug("Daemon started.");
emit resultReady(false, "");
/*}catch(std::exception ex){
}catch(std::exception& ex){
emit resultReady(true, ex.what());
}catch(...){
emit resultReady(true, QObject::tr("Error: unknown exception"));
}*/
}
}
void Worker::restartDaemon()
{
qDebug("Performing daemon restart...");
//try{
try{
m_Daemon.restart();
qDebug("Daemon restarted.");
emit resultReady(false, "");
/*}catch(std::exception ex){
}catch(std::exception& ex){
emit resultReady(true, ex.what());
}catch(...){
emit resultReady(true, QObject::tr("Error: unknown exception"));
}*/
}
}
void Worker::stopDaemon() {
qDebug("Performing daemon stop...");
//try{
try{
m_Daemon.stop();
qDebug("Daemon stopped.");
emit resultReady(false, "");
/*}catch(std::exception ex){
}catch(std::exception& ex){
emit resultReady(true, ex.what());
}catch(...){
emit resultReady(true, QObject::tr("Error: unknown exception"));
}*/
}
}
Controller::Controller(DaemonQTImpl& daemon):

2
src/SaverImpl.cpp

@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
#include "mainwindow.h"
SaverImpl::SaverImpl(MainWindow *mainWindowPtr_, QSharedPointer<QList<MainWindowItem*>> configItems_, QSharedPointer<std::map<std::string,TunnelConfig*>> tunnelConfigs_) :
SaverImpl::SaverImpl(MainWindow *mainWindowPtr_, QList<MainWindowItem*>* configItems_, std::map<std::string,TunnelConfig*>* tunnelConfigs_) :
configItems(configItems_), tunnelConfigs(tunnelConfigs_), confpath(), tunconfpath(), mainWindowPtr(mainWindowPtr_)
{}

7
src/SaverImpl.h

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
#include <QObject>
#include "QList"
#include "QSharedPointer"
#include "mainwindow.h"
#include "TunnelConfig.h"
@ -18,14 +17,14 @@ class TunnelConfig; @@ -18,14 +17,14 @@ class TunnelConfig;
class SaverImpl : public Saver
{
public:
SaverImpl(MainWindow *mainWindowPtr_, QSharedPointer<QList<MainWindowItem*>> configItems_, QSharedPointer<std::map<std::string,TunnelConfig*>> tunnelConfigs_);
SaverImpl(MainWindow *mainWindowPtr_, QList<MainWindowItem*>* configItems_, std::map<std::string,TunnelConfig*>* tunnelConfigs_);
virtual ~SaverImpl();
virtual bool save(bool reloadAfterSave, const FocusEnum focusOn, const std::string& tunnelNameToFocus, QWidget* widgetToFocus);
void setConfPath(QString& confpath_);
void setTunnelsConfPath(QString& tunconfpath_);
private:
QSharedPointer<QList<MainWindowItem*>> configItems;
QSharedPointer<std::map<std::string,TunnelConfig*>> tunnelConfigs;
QList<MainWindowItem*>* configItems;
std::map<std::string,TunnelConfig*>* tunnelConfigs;
QString confpath;
QString tunconfpath;
MainWindow* mainWindowPtr;

4
src/mainwindow.cpp

@ -70,8 +70,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren @@ -70,8 +70,8 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
,tunnelsPageUpdateListener(this)
,saverPtr(
new SaverImpl(this,
QSharedPointer<QList<MainWindowItem*>>(&configItems),
QSharedPointer<std::map<std::string,TunnelConfig*>>(&tunnelConfigs)))
&configItems,
&tunnelConfigs))
{
assert(delayedSaveManagerPtr!=nullptr);

Loading…
Cancel
Save