mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Fix some memory leaks and mismatches
This commit is contained in:
parent
bb5f2e066d
commit
a01e0db7ba
|
@ -1248,7 +1248,7 @@ QString Core::getFriendUsername(uint32_t friendnumber) const
|
|||
uint8_t* name = new uint8_t[namesize];
|
||||
tox_friend_get_name(tox, friendnumber, name, nullptr);
|
||||
QString sname = CString::toString(name, namesize);
|
||||
delete name;
|
||||
delete[] name;
|
||||
return sname;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,11 @@ QRWidget::QRWidget(QWidget *parent) : QWidget(parent), data("0")
|
|||
image = new QImage(size, QImage::Format_RGB32);
|
||||
}
|
||||
|
||||
QRWidget::~QRWidget()
|
||||
{
|
||||
delete image;
|
||||
}
|
||||
|
||||
void QRWidget::setQRData(const QString& data)
|
||||
{
|
||||
this->data = data;
|
||||
|
|
|
@ -11,6 +11,7 @@ class QRWidget : public QWidget
|
|||
|
||||
public:
|
||||
explicit QRWidget(QWidget *parent = 0);
|
||||
~QRWidget();
|
||||
void setQRData(const QString& data);
|
||||
QImage* getImage();
|
||||
bool saveImage(QString path);
|
||||
|
|
|
@ -69,7 +69,7 @@ ChatForm::ChatForm(Friend* chatFriend)
|
|||
|
||||
typingTimer.setSingleShot(true);
|
||||
|
||||
netcam = new NetCamView();
|
||||
netcam = nullptr;
|
||||
callDurationTimer = nullptr;
|
||||
disableCallButtonsTimer = nullptr;
|
||||
|
||||
|
@ -307,7 +307,7 @@ void ChatForm::onAvStart(uint32_t FriendId, int CallId, bool video)
|
|||
connect(videoButton, SIGNAL(clicked()),
|
||||
this, SLOT(onHangupCallTriggered()));
|
||||
|
||||
netcam->show(Core::getInstance()->getVideoSourceFromCall(CallId), f->getDisplayedName());
|
||||
showNetcam();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -349,7 +349,7 @@ void ChatForm::onAvCancel(uint32_t FriendId, int)
|
|||
enableCallButtons();
|
||||
stopCounter();
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
|
||||
addSystemInfoMessage(tr("%1 stopped calling").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ void ChatForm::onAvEnd(uint32_t FriendId, int)
|
|||
|
||||
enableCallButtons();
|
||||
stopCounter();
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
|
||||
|
@ -424,7 +424,7 @@ void ChatForm::onAvStarting(uint32_t FriendId, int CallId, bool video)
|
|||
videoButton->setToolTip(tr("End video call"));
|
||||
connect(videoButton, SIGNAL(clicked()), this, SLOT(onHangupCallTriggered()));
|
||||
|
||||
netcam->show(Core::getInstance()->getVideoSourceFromCall(CallId), f->getDisplayedName());
|
||||
showNetcam();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -453,7 +453,7 @@ void ChatForm::onAvEnding(uint32_t FriendId, int)
|
|||
enableCallButtons();
|
||||
stopCounter();
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRequestTimeout(uint32_t FriendId, int)
|
||||
|
@ -469,7 +469,7 @@ void ChatForm::onAvRequestTimeout(uint32_t FriendId, int)
|
|||
enableCallButtons();
|
||||
stopCounter();
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAvPeerTimeout(uint32_t FriendId, int)
|
||||
|
@ -485,7 +485,7 @@ void ChatForm::onAvPeerTimeout(uint32_t FriendId, int)
|
|||
enableCallButtons();
|
||||
stopCounter();
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAvRejected(uint32_t FriendId, int)
|
||||
|
@ -502,7 +502,7 @@ void ChatForm::onAvRejected(uint32_t FriendId, int)
|
|||
|
||||
insertChatMessage(ChatMessage::createChatInfoMessage(tr("Call rejected"), ChatMessage::INFO, QDateTime::currentDateTime()));
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAvMediaChange(uint32_t FriendId, int CallId, bool video)
|
||||
|
@ -513,9 +513,9 @@ void ChatForm::onAvMediaChange(uint32_t FriendId, int CallId, bool video)
|
|||
qDebug() << "onAvMediaChange";
|
||||
|
||||
if (video)
|
||||
netcam->show(Core::getInstance()->getVideoSourceFromCall(CallId), f->getDisplayedName());
|
||||
showNetcam();
|
||||
else
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
}
|
||||
|
||||
void ChatForm::onAnswerCallTriggered()
|
||||
|
@ -538,7 +538,7 @@ void ChatForm::onHangupCallTriggered()
|
|||
qDebug() << "onHangupCallTriggered";
|
||||
|
||||
//Fixes an OS X bug with ending a call while in full screen
|
||||
if (netcam->isFullScreen())
|
||||
if (netcam && netcam->isFullScreen())
|
||||
netcam->showNormal();
|
||||
|
||||
audioInputFlag = false;
|
||||
|
@ -606,7 +606,7 @@ void ChatForm::onCancelCallTriggered()
|
|||
|
||||
enableCallButtons();
|
||||
|
||||
netcam->hide();
|
||||
hideNetcam();
|
||||
emit cancelCall(callId, f->getFriendID());
|
||||
}
|
||||
|
||||
|
@ -1035,3 +1035,19 @@ void ChatForm::SendMessageStr(QString msg)
|
|||
msgEdit->setLastMessage(msg); //set last message only when sending it
|
||||
}
|
||||
}
|
||||
|
||||
void ChatForm::showNetcam()
|
||||
{
|
||||
if (!netcam)
|
||||
netcam = new NetCamView();
|
||||
netcam->show(Core::getInstance()->getVideoSourceFromCall(callId), f->getDisplayedName());
|
||||
}
|
||||
|
||||
void ChatForm::hideNetcam()
|
||||
{
|
||||
if (!netcam)
|
||||
return;
|
||||
netcam->hide();
|
||||
delete netcam;
|
||||
netcam = nullptr;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,8 @@ private slots:
|
|||
void doScreenshot();
|
||||
|
||||
protected:
|
||||
void showNetcam();
|
||||
void hideNetcam();
|
||||
// drag & drop
|
||||
void dragEnterEvent(QDragEnterEvent* ev);
|
||||
void dropEvent(QDropEvent* ev);
|
||||
|
|
|
@ -49,7 +49,7 @@ void ProfileForm::refreshProfiles()
|
|||
}
|
||||
|
||||
ProfileForm::ProfileForm(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
QWidget{parent}, qr{nullptr}
|
||||
{
|
||||
bodyUI = new Ui::IdentitySettings;
|
||||
bodyUI->setupUi(this);
|
||||
|
@ -132,6 +132,7 @@ ProfileForm::ProfileForm(QWidget *parent) :
|
|||
|
||||
ProfileForm::~ProfileForm()
|
||||
{
|
||||
delete qr;
|
||||
delete bodyUI;
|
||||
head->deleteLater();
|
||||
}
|
||||
|
@ -182,6 +183,7 @@ void ProfileForm::setToxId(const QString& id)
|
|||
toxId->setText(id);
|
||||
toxId->setCursorPosition(0);
|
||||
|
||||
delete qr;
|
||||
qr = new QRWidget();
|
||||
qr->setQRData("tox:"+id);
|
||||
bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150)));
|
||||
|
|
|
@ -26,6 +26,11 @@ MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString
|
|||
setSize(size);
|
||||
}
|
||||
|
||||
MaskablePixmapWidget::~MaskablePixmapWidget()
|
||||
{
|
||||
delete renderTarget;
|
||||
}
|
||||
|
||||
void MaskablePixmapWidget::autopickBackground()
|
||||
{
|
||||
QImage pic = pixmap.toImage();
|
||||
|
|
|
@ -24,7 +24,7 @@ class MaskablePixmapWidget : public QWidget
|
|||
Q_OBJECT
|
||||
public:
|
||||
MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName = QString());
|
||||
|
||||
~MaskablePixmapWidget();
|
||||
void autopickBackground();
|
||||
void setClickable(bool clickable);
|
||||
void setPixmap(const QPixmap &pmap, QColor background);
|
||||
|
|
|
@ -34,8 +34,8 @@ ScreenshotGrabber::ScreenshotGrabber(QWidget* parent)
|
|||
: QWidget(parent)
|
||||
{
|
||||
|
||||
QGraphicsScene* scene = new QGraphicsScene;
|
||||
this->window = new QGraphicsView (scene); // Top-level widget
|
||||
scene = new QGraphicsScene;
|
||||
window = new QGraphicsView (scene); // Top-level widget
|
||||
setupWindow();
|
||||
setupScene(scene);
|
||||
|
||||
|
@ -45,6 +45,7 @@ ScreenshotGrabber::ScreenshotGrabber(QWidget* parent)
|
|||
|
||||
ScreenshotGrabber::~ScreenshotGrabber()
|
||||
{
|
||||
delete scene;
|
||||
}
|
||||
|
||||
bool ScreenshotGrabber::eventFilter(QObject* object, QEvent* event)
|
||||
|
|
|
@ -71,13 +71,13 @@ private:
|
|||
void beginRectChooser(QGraphicsSceneMouseEvent* event);
|
||||
|
||||
QPixmap screenGrab;
|
||||
QGraphicsScene* scene;
|
||||
QGraphicsView* window;
|
||||
QGraphicsPixmapItem* screenGrabDisplay;
|
||||
ScreenGrabberOverlayItem* overlay;
|
||||
ScreenGrabberChooserRectItem* chooserRect;
|
||||
ToolBoxGraphicsItem* helperToolbox;
|
||||
QGraphicsTextItem* helperTooltip;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user