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

fixed crash bug

parent a9a173e3
#include "overlaycontroller.h"
#include <QDesktopWidget>
#include <QTimer>
#include <QStringList>
#include "plugin.h"
#include <qdebug.h>
......@@ -60,7 +59,7 @@ OverlayController::~OverlayController()
delete m_tree;
}
void OverlayController::deleteChatLine(QWidget * line)
void OverlayController::deleteChatLine(QWidget * line, QTimer *timer)
{
//TODO: delete the given line instead of the last
int index = m_msgLines.indexOf(line);
......@@ -69,6 +68,9 @@ void OverlayController::deleteChatLine(QWidget * line)
delete m_msgLines.at(index);
m_msgLines.remove(index);
}
if (timer)
delete timer;
}
void OverlayController::treeItemClicked(QTreeWidgetItem * item, int column)
......@@ -126,7 +128,11 @@ void OverlayController::addChatLine(QString message)
deleteChatLine(m_msgLines.last());
// 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)
......
......@@ -5,6 +5,7 @@
#include <QObject>
#include <QString>
#include <QWidget>
#include <QTimer>
#include <QVector>
#include <QLabel>
#include "ChannelListWidget.h"
......@@ -36,8 +37,10 @@ private:
QVector<QWidget*> m_msgLines;
ChannelListWidget* m_tree;
private:
void deleteChatLine(QWidget* line, QTimer *timer = NULL);
private slots:
void deleteChatLine(QWidget* line);
void treeItemClicked(QTreeWidgetItem * item, int column);
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