mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fixed potential null deref. & memory leak
This commit is contained in:
parent
5429e50bd0
commit
691a8b0b71
|
@ -217,6 +217,9 @@ void Text::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if(!doc)
|
||||||
|
return;
|
||||||
|
|
||||||
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
||||||
|
|
||||||
// open anchors in browser
|
// open anchors in browser
|
||||||
|
@ -231,11 +234,15 @@ QString Text::getText() const
|
||||||
|
|
||||||
void Text::ensureIntegrity()
|
void Text::ensureIntegrity()
|
||||||
{
|
{
|
||||||
if(!doc || dirty)
|
if(!doc)
|
||||||
{
|
{
|
||||||
doc = new CustomTextDocument();
|
doc = new CustomTextDocument();
|
||||||
doc->setDefaultFont(defFont);
|
doc->setDefaultFont(defFont);
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dirty)
|
||||||
|
{
|
||||||
if(!elide)
|
if(!elide)
|
||||||
{
|
{
|
||||||
doc->setHtml(text);
|
doc->setHtml(text);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user