mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Source code maintenance
Memory leaks: - NotifyQt::UpdateGUI -> popup messages (toaster) stay hidden in memory - p3disc::handleIncoming -> item was not deleted when RsDiscHeartbeat (memory leak every tick) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2852 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
03fa79eda0
commit
c3d92dc472
@ -173,6 +173,7 @@ int p3disc::handleIncoming()
|
|||||||
}
|
}
|
||||||
else if (NULL != (dta = dynamic_cast<RsDiscHeartbeat *> (item))) {
|
else if (NULL != (dta = dynamic_cast<RsDiscHeartbeat *> (item))) {
|
||||||
recvHeartbeatMsg(dta);
|
recvHeartbeatMsg(dta);
|
||||||
|
delete item;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
delete item;
|
delete item;
|
||||||
|
@ -49,8 +49,11 @@ MessagesPopupDialog::MessagesPopupDialog(QWidget* parent, Qt::WFlags flags)
|
|||||||
{
|
{
|
||||||
/* Invoke the Qt Designer generated object setup routine */
|
/* Invoke the Qt Designer generated object setup routine */
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
|
|
||||||
messagesdlg = new MessagesDialog();
|
messagesdlg = new MessagesDialog();
|
||||||
|
messagesdlg->setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(ui.centralwidget);
|
QVBoxLayout *layout = new QVBoxLayout(ui.centralwidget);
|
||||||
layout->addWidget(messagesdlg);
|
layout->addWidget(messagesdlg);
|
||||||
|
@ -365,7 +365,7 @@ void NetworkDialog::insertConnect()
|
|||||||
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
||||||
delete connectWidget->takeTopLevelItem(index);
|
delete (connectWidget->takeTopLevelItem(index));
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ void NetworkDialog::insertConnect()
|
|||||||
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
||||||
delete ui.unvalidGPGkeyWidget->takeTopLevelItem(index);
|
delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
|
||||||
} else {
|
} else {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -18,61 +18,61 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include "CallToaster.h"
|
#include "CallToaster.h"
|
||||||
|
|
||||||
#include "QtToaster.h"
|
#include "QtToaster.h"
|
||||||
|
|
||||||
#include "ui_CallToaster.h"
|
#include "ui_CallToaster.h"
|
||||||
|
|
||||||
//#include <util/SafeDelete.h>
|
//#include <util/SafeDelete.h>
|
||||||
//#include <util/SafeConnect.h>
|
//#include <util/SafeConnect.h>
|
||||||
|
|
||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
|
|
||||||
CallToaster::CallToaster()
|
CallToaster::CallToaster()
|
||||||
: QObject(NULL) {
|
: QObject(NULL) {
|
||||||
|
|
||||||
_callToasterWidget = new QWidget(NULL);
|
_callToasterWidget = new QWidget(NULL);
|
||||||
|
|
||||||
_ui = new Ui::CallToaster();
|
_ui = new Ui::CallToaster();
|
||||||
_ui->setupUi(_callToasterWidget);
|
_ui->setupUi(_callToasterWidget);
|
||||||
|
|
||||||
_ui->hangUpButton->setPixmaps(QPixmap(":/images/toaster/hangup.png"),
|
_ui->hangUpButton->setPixmaps(QPixmap(":/images/toaster/hangup.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap(":/images/toaster/hangup.png"),
|
QPixmap(":/images/toaster/hangup.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap());
|
QPixmap());
|
||||||
|
|
||||||
_ui->pickUpButton->setPixmaps(QPixmap(":/images/toaster/pickup.png"),
|
_ui->pickUpButton->setPixmaps(QPixmap(":/images/toaster/pickup.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap(":/images/toaster/pickup.png"),
|
QPixmap(":/images/toaster/pickup.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap());
|
QPixmap());
|
||||||
|
|
||||||
_ui->pickUpButton->setMinimumSize(QSize(48, 56));
|
_ui->pickUpButton->setMinimumSize(QSize(48, 56));
|
||||||
_ui->pickUpButton->setMaximumSize(QSize(48, 56));
|
_ui->pickUpButton->setMaximumSize(QSize(48, 56));
|
||||||
connect(_ui->pickUpButton, SIGNAL(clicked()), SLOT(pickUpButtonSlot()));
|
connect(_ui->pickUpButton, SIGNAL(clicked()), SLOT(pickUpButtonSlot()));
|
||||||
|
|
||||||
_ui->hangUpButton->setMinimumSize(QSize(28, 56));
|
_ui->hangUpButton->setMinimumSize(QSize(28, 56));
|
||||||
_ui->hangUpButton->setMaximumSize(QSize(28, 56));
|
_ui->hangUpButton->setMaximumSize(QSize(28, 56));
|
||||||
connect(_ui->hangUpButton, SIGNAL(clicked()), SLOT(hangUpButtonSlot()));
|
connect(_ui->hangUpButton, SIGNAL(clicked()), SLOT(hangUpButtonSlot()));
|
||||||
|
|
||||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
_toaster = new QtToaster(_callToasterWidget, _ui->windowFrame);
|
_toaster = new QtToaster(this, _callToasterWidget, _ui->windowFrame);
|
||||||
_toaster->setTimeOnTop(10000);
|
_toaster->setTimeOnTop(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
CallToaster::~CallToaster() {
|
CallToaster::~CallToaster() {
|
||||||
delete(_ui);
|
delete(_ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallToaster::setMessage(const QString & message) {
|
void CallToaster::setMessage(const QString & message) {
|
||||||
_ui->messageLabel->setText(message);
|
_ui->messageLabel->setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallToaster::setPixmap(const QPixmap & pixmap) {
|
void CallToaster::setPixmap(const QPixmap & pixmap) {
|
||||||
_ui->pixmapLabel->setPixmap(pixmap);
|
_ui->pixmapLabel->setPixmap(pixmap);
|
||||||
@ -80,18 +80,18 @@ void CallToaster::setPixmap(const QPixmap & pixmap) {
|
|||||||
|
|
||||||
void CallToaster::show() {
|
void CallToaster::show() {
|
||||||
_toaster->show();
|
_toaster->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallToaster::close() {
|
void CallToaster::close() {
|
||||||
_toaster->close();
|
_toaster->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallToaster::hangUpButtonSlot() {
|
void CallToaster::hangUpButtonSlot() {
|
||||||
hangUpButtonClicked();
|
hangUpButtonClicked();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallToaster::pickUpButtonSlot() {
|
void CallToaster::pickUpButtonSlot() {
|
||||||
pickUpButtonClicked();
|
pickUpButtonClicked();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -18,23 +18,23 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#include "ChatToaster.h"
|
#include "ChatToaster.h"
|
||||||
|
|
||||||
#include "ui_ChatToaster.h"
|
#include "ui_ChatToaster.h"
|
||||||
|
|
||||||
#include "QtToaster.h"
|
#include "QtToaster.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QtGui/QtGui>
|
#include <QtGui/QtGui>
|
||||||
|
|
||||||
ChatToaster::ChatToaster()
|
ChatToaster::ChatToaster()
|
||||||
: QObject(NULL) {
|
: QObject(NULL) {
|
||||||
|
|
||||||
_chatToasterWidget = new QWidget(NULL);
|
_chatToasterWidget = new QWidget(NULL);
|
||||||
|
|
||||||
_ui = new Ui::ChatToaster();
|
_ui = new Ui::ChatToaster();
|
||||||
_ui->setupUi(_chatToasterWidget);
|
_ui->setupUi(_chatToasterWidget);
|
||||||
|
|
||||||
_ui->chatButton->setPixmaps(QPixmap(":/images/toaster/chat.png"),
|
_ui->chatButton->setPixmaps(QPixmap(":/images/toaster/chat.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
@ -42,22 +42,22 @@ ChatToaster::ChatToaster()
|
|||||||
QPixmap(":/images/toaster/chat.png"),
|
QPixmap(":/images/toaster/chat.png"),
|
||||||
QPixmap(),
|
QPixmap(),
|
||||||
QPixmap());
|
QPixmap());
|
||||||
|
|
||||||
connect(_ui->chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
|
connect(_ui->chatButton, SIGNAL(clicked()), SLOT(chatButtonSlot()));
|
||||||
|
|
||||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
_toaster = new QtToaster(_chatToasterWidget, _ui->windowFrame);
|
_toaster = new QtToaster(this, _chatToasterWidget, _ui->windowFrame);
|
||||||
_toaster->setTimeOnTop(5000);
|
_toaster->setTimeOnTop(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatToaster::~ChatToaster() {
|
ChatToaster::~ChatToaster() {
|
||||||
delete(_ui);
|
delete(_ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatToaster::setMessage(const QString & message) {
|
void ChatToaster::setMessage(const QString & message) {
|
||||||
_ui->messageLabel->setText(message);
|
_ui->messageLabel->setText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatToaster::setPixmap(const QPixmap & pixmap) {
|
void ChatToaster::setPixmap(const QPixmap & pixmap) {
|
||||||
_ui->pixmapLabel->setPixmap(pixmap);
|
_ui->pixmapLabel->setPixmap(pixmap);
|
||||||
@ -66,12 +66,12 @@ void ChatToaster::setPixmap(const QPixmap & pixmap) {
|
|||||||
void ChatToaster::show() {
|
void ChatToaster::show() {
|
||||||
_toaster->show();
|
_toaster->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatToaster::close() {
|
void ChatToaster::close() {
|
||||||
_toaster->close();
|
_toaster->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatToaster::chatButtonSlot() {
|
void ChatToaster::chatButtonSlot() {
|
||||||
chatButtonClicked();
|
chatButtonClicked();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ ForumsToaster::ForumsToaster()
|
|||||||
|
|
||||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
_toaster = new QtToaster(_ForumsToasterWidget, _ui->windowFrame);
|
_toaster = new QtToaster(this, _ForumsToasterWidget, _ui->windowFrame);
|
||||||
_toaster->setTimeOnTop(5000);
|
_toaster->setTimeOnTop(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ GroupChatToaster::GroupChatToaster()
|
|||||||
|
|
||||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
_toaster = new QtToaster(_GroupChatToasterWidget, _ui->windowFrame);
|
_toaster = new QtToaster(this, _GroupChatToasterWidget, _ui->windowFrame);
|
||||||
_toaster->setTimeOnTop(5000);
|
_toaster->setTimeOnTop(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ MessageToaster::MessageToaster( QWidget * parent, Qt::WFlags f)
|
|||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
// set window flags
|
|
||||||
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
|
|
||||||
|
// set window flags
|
||||||
QWidget::setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
QWidget::setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||||
// init the timer
|
// init the timer
|
||||||
displayTimer = new QTimer(this);
|
displayTimer = new QTimer(this);
|
||||||
@ -45,7 +48,10 @@ MessageToaster::~MessageToaster()
|
|||||||
|
|
||||||
void MessageToaster::displayTimerOnTimer()
|
void MessageToaster::displayTimerOnTimer()
|
||||||
{
|
{
|
||||||
if (!isVisible()) return;
|
if (!isVisible()) {
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
QRect availableGeometry = desktop->availableGeometry(this);
|
QRect availableGeometry = desktop->availableGeometry(this);
|
||||||
@ -68,6 +74,7 @@ void MessageToaster::displayTimerOnTimer()
|
|||||||
displayState = dsWaiting;
|
displayState = dsWaiting;
|
||||||
displayTimer->stop();
|
displayTimer->stop();
|
||||||
hide();
|
hide();
|
||||||
|
close();
|
||||||
}
|
}
|
||||||
else if (displayState == dsWaiting)
|
else if (displayState == dsWaiting)
|
||||||
{
|
{
|
||||||
@ -97,8 +104,10 @@ void MessageToaster::closeClicked()
|
|||||||
|
|
||||||
void MessageToaster::openmessageClicked()
|
void MessageToaster::openmessageClicked()
|
||||||
{
|
{
|
||||||
static MessagesPopupDialog *msgdialog = new MessagesPopupDialog();
|
MessagesPopupDialog *msgdialog = new MessagesPopupDialog();
|
||||||
msgdialog->show();
|
msgdialog->show();
|
||||||
|
|
||||||
|
/* window will destroy itself! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageToaster::setMessage(const QString & message)
|
void MessageToaster::setMessage(const QString & message)
|
||||||
|
@ -37,7 +37,7 @@ OnlineToaster::OnlineToaster()
|
|||||||
|
|
||||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||||
|
|
||||||
_toaster = new QtToaster(_onlineToasterWidget, _ui->windowFrame);
|
_toaster = new QtToaster(this, _onlineToasterWidget, _ui->windowFrame);
|
||||||
_toaster->setTimeOnTop(5000);
|
_toaster->setTimeOnTop(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
static const unsigned TIME_TO_SHOW = 20;
|
static const unsigned TIME_TO_SHOW = 20;
|
||||||
|
|
||||||
QtToaster::QtToaster(QWidget * toaster, QFrame * toasterWindowFrame)
|
QtToaster::QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame)
|
||||||
: QObject(toaster) {
|
: QObject(toaster) {
|
||||||
|
|
||||||
_timer = NULL;
|
_timer = NULL;
|
||||||
@ -36,14 +36,23 @@ QtToaster::QtToaster(QWidget * toaster, QFrame * toasterWindowFrame)
|
|||||||
|
|
||||||
_toaster = toaster;
|
_toaster = toaster;
|
||||||
_toaster->setParent(_toaster->parentWidget(), Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
_toaster->setParent(_toaster->parentWidget(), Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
_toaster->setWindowFlags(_toaster->windowFlags() | Qt::ToolTip);
|
|
||||||
|
|
||||||
WidgetBackgroundImage::setBackgroundImage(toasterWindowFrame, ":images/toaster/toaster-backrs4.png", WidgetBackgroundImage::AdjustSize);
|
_toaster->setWindowFlags(_toaster->windowFlags() | Qt::ToolTip);
|
||||||
|
_toaster->setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
|
|
||||||
|
_master = master;
|
||||||
|
WidgetBackgroundImage::setBackgroundImage(toasterWindowFrame, ":images/toaster/toaster-backrs4.png", WidgetBackgroundImage::AdjustSize);
|
||||||
|
|
||||||
_toaster->resize(184, 128);
|
_toaster->resize(184, 128);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtToaster::~QtToaster()
|
||||||
|
{
|
||||||
|
if (_master) {
|
||||||
|
delete (_master);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QtToaster::setTimeOnTop(unsigned time) {
|
void QtToaster::setTimeOnTop(unsigned time) {
|
||||||
_timeOnTop = time;
|
_timeOnTop = time;
|
||||||
}
|
}
|
||||||
@ -53,6 +62,8 @@ void QtToaster::close() {
|
|||||||
_timer->stop();
|
_timer->stop();
|
||||||
}
|
}
|
||||||
_toaster->close();
|
_toaster->close();
|
||||||
|
|
||||||
|
delete (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtToaster::show() {
|
void QtToaster::show() {
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
****************************************************************/
|
****************************************************************/
|
||||||
|
|
||||||
#ifndef QTTOASTER_H
|
#ifndef QTTOASTER_H
|
||||||
#define QTTOASTER_H
|
#define QTTOASTER_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
@ -34,12 +34,13 @@ class QFrame;
|
|||||||
* This class helps factorizing the code between QtCallToaster and QtChatToaster.
|
* This class helps factorizing the code between QtCallToaster and QtChatToaster.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class QtToaster : public QObject {
|
class QtToaster : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QtToaster(QWidget * toaster, QFrame * toasterWindowFrame);
|
QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame);
|
||||||
|
~QtToaster();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the time with the toaster on top.
|
* Sets the time with the toaster on top.
|
||||||
@ -55,16 +56,18 @@ public:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
|
|
||||||
void changeToasterPosition();
|
void changeToasterPosition();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QWidget * _toaster;
|
QWidget * _toaster;
|
||||||
|
|
||||||
QTimer * _timer;
|
QObject *_master;
|
||||||
|
|
||||||
|
QTimer * _timer;
|
||||||
|
|
||||||
bool _show;
|
bool _show;
|
||||||
|
|
||||||
unsigned _timeOnTop;
|
unsigned _timeOnTop;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //QTTOASTER_H
|
#endif //QTTOASTER_H
|
||||||
|
Loading…
Reference in New Issue
Block a user