Commit 1fe231e5 authored by Carsten Fuhrmann's avatar Carsten Fuhrmann
Browse files

fixed crash bug

parent a9a173e3
#include "overlaycontroller.h" #include "overlaycontroller.h"
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QTimer>
#include <QStringList> #include <QStringList>
#include "plugin.h" #include "plugin.h"
#include <qdebug.h> #include <qdebug.h>
...@@ -60,7 +59,7 @@ OverlayController::~OverlayController() ...@@ -60,7 +59,7 @@ OverlayController::~OverlayController()
delete m_tree; delete m_tree;
} }
void OverlayController::deleteChatLine(QWidget * line) void OverlayController::deleteChatLine(QWidget * line, QTimer *timer)
{ {
//TODO: delete the given line instead of the last //TODO: delete the given line instead of the last
int index = m_msgLines.indexOf(line); int index = m_msgLines.indexOf(line);
...@@ -69,6 +68,9 @@ void OverlayController::deleteChatLine(QWidget * line) ...@@ -69,6 +68,9 @@ void OverlayController::deleteChatLine(QWidget * line)
delete m_msgLines.at(index); delete m_msgLines.at(index);
m_msgLines.remove(index); m_msgLines.remove(index);
} }
if (timer)
delete timer;
} }
void OverlayController::treeItemClicked(QTreeWidgetItem * item, int column) void OverlayController::treeItemClicked(QTreeWidgetItem * item, int column)
...@@ -126,7 +128,11 @@ void OverlayController::addChatLine(QString message) ...@@ -126,7 +128,11 @@ void OverlayController::addChatLine(QString message)
deleteChatLine(m_msgLines.last()); deleteChatLine(m_msgLines.last());
// hide after time // hide after time
QTimer::singleShot(TIMEOUT, [=]() {deleteChatLine(w);}); QTimer* timer = new QTimer(this);
timer->setSingleShot(true);
timer->setInterval(TIMEOUT);
connect(timer, &QTimer::timeout, [=]() {deleteChatLine(w, timer);});
timer->start();
} }
void OverlayController::addSpeaker(QString name) void OverlayController::addSpeaker(QString name)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QWidget> #include <QWidget>
#include <QTimer>
#include <QVector> #include <QVector>
#include <QLabel> #include <QLabel>
#include "ChannelListWidget.h" #include "ChannelListWidget.h"
...@@ -36,8 +37,10 @@ private: ...@@ -36,8 +37,10 @@ private:
QVector<QWidget*> m_msgLines; QVector<QWidget*> m_msgLines;
ChannelListWidget* m_tree; ChannelListWidget* m_tree;
private:
void deleteChatLine(QWidget* line, QTimer *timer = NULL);
private slots: private slots:
void deleteChatLine(QWidget* line);
void treeItemClicked(QTreeWidgetItem * item, int column); void treeItemClicked(QTreeWidgetItem * item, int column);
public: public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment