From a51169e13f3136700c78771179f3956ba91f8194 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Thu, 29 Oct 2015 14:28:31 +0100 Subject: Connect to/disconnect from IRC in applyConfig instead of CRSM- constructor --- src/crsm.cpp | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'src/crsm.cpp') diff --git a/src/crsm.cpp b/src/crsm.cpp index 73828b6..9bc2a19 100644 --- a/src/crsm.cpp +++ b/src/crsm.cpp @@ -77,15 +77,6 @@ CRSM::CRSM(QObject *parent) : reallog->open(QIODevice::Append | QIODevice::Text); logstream.setDevice(reallog); - if(Config.IRC.Use) - { - prepareAndConnectIrc(); - } - else - { - Config.IRC.UseIngameChat = false; - } - ok = true; } @@ -489,9 +480,14 @@ void CRSM::ircMessageReceived(IrcMessage *message) void CRSM::ircDisconnected() { - if(!finish) + if(connection != nullptr) + { + delete connection; + } + connection = nullptr; + if(!finish && Config.IRC.Use) { - reconnectIrc(); + QTimer::singleShot(Config.IRC.ReconnectDelay * 1000, this, SLOT(reconnectIrc())); } } @@ -1551,8 +1547,11 @@ void CRSM::prepareAndConnectIrc() void CRSM::reconnectIrc() { - connection->close(); - delete connection; + if(connection != nullptr) + { + connection->close(); + delete connection; + } prepareAndConnectIrc(); } @@ -1629,6 +1628,23 @@ void CRSM::applyConfig() ok = false; exit(); } + + if(Config.IRC.Use) + { + if(connection == nullptr) + { + prepareAndConnectIrc(); + } + } + else + { + Config.IRC.UseIngameChat = false; + if(connection != nullptr) + { + connection->quit(Config.IRC.QuitMessage); + } + } + setupCmds(); out(Stats.read(Config.CRSM.StatsFile)); out(Packs.read(Config.CRSM.PacksFile, Config.Auto.Volatile.Clonk.Directory)); -- cgit v1.2.3-54-g00ecf