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))) {
|
||||
recvHeartbeatMsg(dta);
|
||||
delete item;
|
||||
return 1;
|
||||
}
|
||||
delete item;
|
||||
|
@ -50,7 +50,10 @@ MessagesPopupDialog::MessagesPopupDialog(QWidget* parent, Qt::WFlags flags)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
messagesdlg = new MessagesDialog();
|
||||
messagesdlg->setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(ui.centralwidget);
|
||||
layout->addWidget(messagesdlg);
|
||||
|
@ -365,7 +365,7 @@ void NetworkDialog::insertConnect()
|
||||
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
||||
delete connectWidget->takeTopLevelItem(index);
|
||||
delete (connectWidget->takeTopLevelItem(index));
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
@ -375,7 +375,7 @@ void NetworkDialog::insertConnect()
|
||||
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
||||
delete ui.unvalidGPGkeyWidget->takeTopLevelItem(index);
|
||||
delete (ui.unvalidGPGkeyWidget->takeTopLevelItem(index));
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ CallToaster::CallToaster()
|
||||
|
||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
_toaster = new QtToaster(_callToasterWidget, _ui->windowFrame);
|
||||
_toaster = new QtToaster(this, _callToasterWidget, _ui->windowFrame);
|
||||
_toaster->setTimeOnTop(10000);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ ChatToaster::ChatToaster()
|
||||
|
||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
_toaster = new QtToaster(_chatToasterWidget, _ui->windowFrame);
|
||||
_toaster = new QtToaster(this, _chatToasterWidget, _ui->windowFrame);
|
||||
_toaster->setTimeOnTop(5000);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ ForumsToaster::ForumsToaster()
|
||||
|
||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
_toaster = new QtToaster(_ForumsToasterWidget, _ui->windowFrame);
|
||||
_toaster = new QtToaster(this, _ForumsToasterWidget, _ui->windowFrame);
|
||||
_toaster->setTimeOnTop(5000);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ GroupChatToaster::GroupChatToaster()
|
||||
|
||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
_toaster = new QtToaster(_GroupChatToasterWidget, _ui->windowFrame);
|
||||
_toaster = new QtToaster(this, _GroupChatToasterWidget, _ui->windowFrame);
|
||||
_toaster->setTimeOnTop(5000);
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,9 @@ MessageToaster::MessageToaster( QWidget * parent, Qt::WFlags f)
|
||||
: QWidget(parent, f)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
// set window flags
|
||||
QWidget::setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
|
||||
// init the timer
|
||||
@ -45,7 +48,10 @@ MessageToaster::~MessageToaster()
|
||||
|
||||
void MessageToaster::displayTimerOnTimer()
|
||||
{
|
||||
if (!isVisible()) return;
|
||||
if (!isVisible()) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
QRect availableGeometry = desktop->availableGeometry(this);
|
||||
@ -68,6 +74,7 @@ void MessageToaster::displayTimerOnTimer()
|
||||
displayState = dsWaiting;
|
||||
displayTimer->stop();
|
||||
hide();
|
||||
close();
|
||||
}
|
||||
else if (displayState == dsWaiting)
|
||||
{
|
||||
@ -97,8 +104,10 @@ void MessageToaster::closeClicked()
|
||||
|
||||
void MessageToaster::openmessageClicked()
|
||||
{
|
||||
static MessagesPopupDialog *msgdialog = new MessagesPopupDialog();
|
||||
MessagesPopupDialog *msgdialog = new MessagesPopupDialog();
|
||||
msgdialog->show();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void MessageToaster::setMessage(const QString & message)
|
||||
|
@ -37,7 +37,7 @@ OnlineToaster::OnlineToaster()
|
||||
|
||||
connect(_ui->closeButton, SIGNAL(clicked()), SLOT(close()));
|
||||
|
||||
_toaster = new QtToaster(_onlineToasterWidget, _ui->windowFrame);
|
||||
_toaster = new QtToaster(this, _onlineToasterWidget, _ui->windowFrame);
|
||||
_toaster->setTimeOnTop(5000);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
static const unsigned TIME_TO_SHOW = 20;
|
||||
|
||||
QtToaster::QtToaster(QWidget * toaster, QFrame * toasterWindowFrame)
|
||||
QtToaster::QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame)
|
||||
: QObject(toaster) {
|
||||
|
||||
_timer = NULL;
|
||||
@ -38,12 +38,21 @@ QtToaster::QtToaster(QWidget * toaster, QFrame * toasterWindowFrame)
|
||||
_toaster->setParent(_toaster->parentWidget(), Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
|
||||
_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);
|
||||
}
|
||||
|
||||
QtToaster::~QtToaster()
|
||||
{
|
||||
if (_master) {
|
||||
delete (_master);
|
||||
}
|
||||
}
|
||||
|
||||
void QtToaster::setTimeOnTop(unsigned time) {
|
||||
_timeOnTop = time;
|
||||
}
|
||||
@ -53,6 +62,8 @@ void QtToaster::close() {
|
||||
_timer->stop();
|
||||
}
|
||||
_toaster->close();
|
||||
|
||||
delete (this);
|
||||
}
|
||||
|
||||
void QtToaster::show() {
|
||||
|
@ -39,7 +39,8 @@ class QtToaster : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
QtToaster(QWidget * toaster, QFrame * toasterWindowFrame);
|
||||
QtToaster(QObject *master, QWidget * toaster, QFrame * toasterWindowFrame);
|
||||
~QtToaster();
|
||||
|
||||
/**
|
||||
* Sets the time with the toaster on top.
|
||||
@ -60,6 +61,8 @@ private:
|
||||
|
||||
QWidget * _toaster;
|
||||
|
||||
QObject *_master;
|
||||
|
||||
QTimer * _timer;
|
||||
|
||||
bool _show;
|
||||
|
Loading…
Reference in New Issue
Block a user