From ee74a4c8b0d8563f994004395fe2b45fcdfef04e Mon Sep 17 00:00:00 2001
From: J-P Nurmi <jpnurmi@digia.com>
Date: Fri, 2 Aug 2013 16:43:06 +0200
Subject: [PATCH] QWinTaskbarButton: minor tweaks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Make the constructor's parent argument optional, and do not
pass a pointer to a half constructed object to the private
implementation.

Change-Id: I48df98f8d55ec49fd8f155b14167038055712cfc
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
---
 src/winextras/qwintaskbarbutton.cpp | 8 +++++---
 src/winextras/qwintaskbarbutton.h   | 2 +-
 src/winextras/qwintaskbarbutton_p.h | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/winextras/qwintaskbarbutton.cpp b/src/winextras/qwintaskbarbutton.cpp
index 86c6e0e..192987b 100644
--- a/src/winextras/qwintaskbarbutton.cpp
+++ b/src/winextras/qwintaskbarbutton.cpp
@@ -88,8 +88,10 @@ QT_BEGIN_NAMESPACE
     Constructs a QWinTaskbarButton with the parent object \a parent.
  */
 QWinTaskbarButton::QWinTaskbarButton(QObject *parent) :
-    QObject(parent), d_ptr(new QWinTaskbarButtonPrivate(this))
+    QObject(parent), d_ptr(new QWinTaskbarButtonPrivate)
 {
+    Q_D(QWinTaskbarButton);
+    d->q_ptr = this;
     QWinEventFilter::setup();
 }
 
@@ -294,9 +296,9 @@ void QWinTaskbarButton::resetProgress()
 
 
 
-QWinTaskbarButtonPrivate::QWinTaskbarButtonPrivate(QWinTaskbarButton *parent) :
+QWinTaskbarButtonPrivate::QWinTaskbarButtonPrivate() :
     progressMinimum(0), progressMaximum(100), progressValue(0), progressState(QWinTaskbarButton::NoProgressState),
-    updateNeeded(false), pTbList(0), window(0), q_ptr(parent)
+    updateNeeded(false), pTbList(0), window(0), q_ptr(0)
 {
     HRESULT hresult = CoCreateInstance(CLSID_TaskbarList, 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList4, reinterpret_cast<void **>(&pTbList));
     if (FAILED(hresult)) {
diff --git a/src/winextras/qwintaskbarbutton.h b/src/winextras/qwintaskbarbutton.h
index 85efd3f..562e1f6 100644
--- a/src/winextras/qwintaskbarbutton.h
+++ b/src/winextras/qwintaskbarbutton.h
@@ -71,7 +71,7 @@ public:
 
     Q_ENUMS(ProgressState)
 
-    explicit QWinTaskbarButton(QObject *parent);
+    explicit QWinTaskbarButton(QObject *parent = 0);
     ~QWinTaskbarButton();
     void setWindow(QWindow *window);
 
diff --git a/src/winextras/qwintaskbarbutton_p.h b/src/winextras/qwintaskbarbutton_p.h
index 92caf9b..51dc657 100644
--- a/src/winextras/qwintaskbarbutton_p.h
+++ b/src/winextras/qwintaskbarbutton_p.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
 class QWinTaskbarButtonPrivate
 {
 public:
-    explicit QWinTaskbarButtonPrivate(QWinTaskbarButton *parent);
+    QWinTaskbarButtonPrivate();
     ~QWinTaskbarButtonPrivate();
 
     int progressMinimum;
-- 
GitLab