Browse Source

BUG: Fix ctkDoubleSpinBox memory corruption

The ctkDoubleSpinBoxPrivate instance is used by both ctkDoubleSpinBox and the
ctkQDoubleSpinBox that the private instance creates. The private instance adds
the ctkQDoubleSpinBox instance as a child of the ctkDoubleSpinBox instance.
This commit moves ownership of the ctkDoubleSpinBoxPrivate instance from
ctkDoubleSpinBox to ctkQDoubleSpinBox to ensure a destruction order that doesn't
cause memory corruption.
Max Smolens 7 years ago
parent
commit
dda5440c2c
2 changed files with 2 additions and 2 deletions
  1. 1 1
      Libs/Widgets/ctkDoubleSpinBox.h
  2. 1 1
      Libs/Widgets/ctkDoubleSpinBox_p.h

+ 1 - 1
Libs/Widgets/ctkDoubleSpinBox.h

@@ -320,7 +320,7 @@ Q_SIGNALS:
   void decimalsChanged(int);
 
 protected:
-  QScopedPointer<ctkDoubleSpinBoxPrivate> d_ptr;
+  ctkDoubleSpinBoxPrivate* const d_ptr;
 
   /// Reimplemented to support shortcuts.
   virtual void keyPressEvent(QKeyEvent* event);

+ 1 - 1
Libs/Widgets/ctkDoubleSpinBox_p.h

@@ -59,7 +59,7 @@ public:
   /// Expose publicly QAbstractSpinBox::initStyleOption()
   void initStyleOptionSpinBox(QStyleOptionSpinBox* option);
 protected:
-  ctkDoubleSpinBoxPrivate* const d_ptr;
+  QScopedPointer<ctkDoubleSpinBoxPrivate> d_ptr;
 
   /// If the invertedControls property is false (by default) then this function
   /// behavesLike QDoubleSpinBox::stepEnabled(). If the property is true then