[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konsole] src: Use QPointer for QDrag widget
From:       Kurt Hindenburg <kurt.hindenburg () gmail ! com>
Date:       2016-09-04 23:39:20
Message-ID: E1bgh0S-0001Gv-B8 () code ! kde ! org
[Download RAW message or body]

Git commit 7a97832d9a02af74f179f761adbce704af761f3f by Kurt Hindenburg.
Committed on 04/09/2016 at 23:38.
Pushed by hindenburg into branch 'master'.

Use QPointer for QDrag widget

Add QPointer guard around QDrag exec()

M  +3    -2    src/ViewContainer.cpp

http://commits.kde.org/konsole/7a97832d9a02af74f179f761adbce704af761f3f

diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp
index 7e19353..f0017fd 100644
--- a/src/ViewContainer.cpp
+++ b/src/ViewContainer.cpp
@@ -443,7 +443,7 @@ TabbedViewContainer::~TabbedViewContainer()
 
 void TabbedViewContainer::startTabDrag(int tab)
 {
-    QDrag* drag = new QDrag(_tabBar);
+    QPointer<QDrag> drag = new QDrag(_tabBar);
     const QRect tabRect = _tabBar->tabRect(tab);
     QPixmap tabPixmap = _tabBar->dragDropPixmap(tab);
 
@@ -463,7 +463,7 @@ void TabbedViewContainer::startTabDrag(int tab)
     // start dragging
     const Qt::DropAction action = drag->exec();
 
-    if (drag->target()) {
+    if (drag && drag->target()) {
         switch (action) {
         case Qt::MoveAction:
             // The MoveAction indicates the widget has been successfully
@@ -501,6 +501,7 @@ void TabbedViewContainer::startTabDrag(int tab)
         if (_tabBar->count() > 1)
             emit detachTab(this, view);
     }
+    delete drag;
 }
 
 void TabbedViewContainer::querySourceIndex(const QDropEvent* event, int& sourceIndex)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic