This repository was archived by the owner on Dec 10, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2424#include < QHostInfo>
2525#include < QTcpSocket>
2626
27+ #ifndef USE_BOTAN2
2728#include < botan/init.h>
29+ #endif
2830
2931#include " controller.h"
3032#include " encryptor.h"
@@ -44,7 +46,7 @@ Controller::Controller(Profile _profile,
4446{
4547#ifndef USE_BOTAN2
4648 try {
47- Botan::LibraryInitializer::initialize (" thread_safe" );
49+ botanInit = std::make_unique<Botan::LibraryInitializer> (" thread_safe" );
4850 } catch (std::exception &e) {
4951 qFatal (" Failed to initialise Botan library: %s" , e.what ());
5052 }
@@ -99,9 +101,6 @@ Controller::~Controller()
99101 if (tcpServer->isListening ()) {
100102 stop ();
101103 }
102- #ifndef USE_BOTAN2
103- Botan::LibraryInitializer::deinitialize ();
104- #endif
105104}
106105
107106bool Controller::start ()
Original file line number Diff line number Diff line change 3131#include " profile.h"
3232#include " udprelay.h"
3333
34+ #ifndef USE_BOTAN2
35+ namespace Botan {
36+ class LibraryInitializer ;
37+ }
38+ #endif
39+
3440namespace QSS {
3541
3642class QSS_EXPORT Controller : public QObject
@@ -71,6 +77,12 @@ public slots:
7177 bool start (); // Return true if start successfully, otherwise return false
7278 void stop ();
7379
80+ private:
81+ #ifndef USE_BOTAN2
82+ // This needs to be destructed in the end
83+ std::unique_ptr<Botan::LibraryInitializer> botanInit;
84+ #endif
85+
7486protected:
7587 // The total bytes recevied or sent by/from all TCP and UDP connections.
7688 uint64_t bytesReceived;
You can’t perform that action at this time.
0 commit comments