From bfb59228c11614761bc1203a19845cc937a51918 Mon Sep 17 00:00:00 2001 From: Graham Dawes Date: Thu, 20 Dec 2018 10:38:50 +0000 Subject: [PATCH 01/10] Fix crashes due to unitialised fields --- src/qt/app.cpp | 2 ++ src/qt/checkbox.cpp | 3 ++- src/qt/choice.cpp | 3 ++- src/qt/combobox.cpp | 5 +++-- src/qt/gauge.cpp | 3 ++- src/qt/listbox.cpp | 3 ++- src/qt/listctrl.cpp | 1 + src/qt/notebook.cpp | 3 ++- src/qt/radiobox.cpp | 10 ++++++++-- src/qt/radiobut.cpp | 3 ++- src/qt/scrolbar.cpp | 3 ++- src/qt/slider.cpp | 3 ++- src/qt/spinbutt.cpp | 3 ++- src/qt/spinctrl.cpp | 3 ++- src/qt/statbmp.cpp | 3 ++- src/qt/statbox.cpp | 3 ++- src/qt/statline.cpp | 3 ++- src/qt/stattext.cpp | 3 ++- src/qt/statusbar.cpp | 1 + src/qt/textctrl.cpp | 4 +++- 20 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/qt/app.cpp b/src/qt/app.cpp index 93f0ccd3d8..7c6033c0fc 100644 --- a/src/qt/app.cpp +++ b/src/qt/app.cpp @@ -20,6 +20,8 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxApp, wxAppBase); wxApp::wxApp() { m_qtApplication = NULL; + m_qtArgc = 0; + m_qtArgv = NULL; } diff --git a/src/qt/checkbox.cpp b/src/qt/checkbox.cpp index c248531f72..0554e1c6d1 100644 --- a/src/qt/checkbox.cpp +++ b/src/qt/checkbox.cpp @@ -46,7 +46,8 @@ void wxQtCheckBox::clicked( bool checked ) } -wxCheckBox::wxCheckBox() +wxCheckBox::wxCheckBox() : + m_qtCheckBox(NULL) { } diff --git a/src/qt/choice.cpp b/src/qt/choice.cpp index 2716a9c004..1bd6511202 100644 --- a/src/qt/choice.cpp +++ b/src/qt/choice.cpp @@ -37,7 +37,8 @@ void wxQtChoice::activated(int WXUNUSED(index)) } -wxChoice::wxChoice() +wxChoice::wxChoice() : + m_qtComboBox(NULL) { } diff --git a/src/qt/combobox.cpp b/src/qt/combobox.cpp index 1080721625..4ca376f23d 100644 --- a/src/qt/combobox.cpp +++ b/src/qt/combobox.cpp @@ -112,8 +112,9 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxValidator& validator, const wxString& name ) { - return Create( parent, id, value, pos, size, choices.size(), &choices[ 0 ], - style, validator, name ); + const wxString *pChoices = choices.size() ? &choices[ 0 ] : NULL; + return Create(parent, id, value, pos, size, choices.size(), pChoices, + style, validator, name ); } diff --git a/src/qt/gauge.cpp b/src/qt/gauge.cpp index 8952043db8..38df21aa35 100644 --- a/src/qt/gauge.cpp +++ b/src/qt/gauge.cpp @@ -29,7 +29,8 @@ wxQtProgressBar::wxQtProgressBar( wxWindow *parent, wxGauge *handler ) } -wxGauge::wxGauge() +wxGauge::wxGauge() : + m_qtProgressBar(NULL) { } diff --git a/src/qt/listbox.cpp b/src/qt/listbox.cpp index be40ae320f..2b60223f70 100644 --- a/src/qt/listbox.cpp +++ b/src/qt/listbox.cpp @@ -45,7 +45,8 @@ void wxQtListWidget::doubleClicked( const QModelIndex &index ) } -wxListBox::wxListBox() +wxListBox::wxListBox() : + m_qtListWidget(NULL) { Init(); } diff --git a/src/qt/listctrl.cpp b/src/qt/listctrl.cpp index 8a087ef07d..556021c003 100644 --- a/src/qt/listctrl.cpp +++ b/src/qt/listctrl.cpp @@ -154,6 +154,7 @@ void wxListCtrl::Init() m_ownsImageListSmall = false; m_imageListState = NULL; m_ownsImageListState = false; + m_qtTreeWidget = NULL; } wxListCtrl::~wxListCtrl() diff --git a/src/qt/notebook.cpp b/src/qt/notebook.cpp index 3730c67782..4f00fa31f1 100644 --- a/src/qt/notebook.cpp +++ b/src/qt/notebook.cpp @@ -50,7 +50,8 @@ void wxQtTabWidget::currentChanged(int index) } -wxNotebook::wxNotebook() +wxNotebook::wxNotebook() : + m_qtTabWidget(NULL) { } diff --git a/src/qt/radiobox.cpp b/src/qt/radiobox.cpp index b8c82a8a37..22706e8038 100644 --- a/src/qt/radiobox.cpp +++ b/src/qt/radiobox.cpp @@ -56,7 +56,10 @@ void wxQtButtonGroup::buttonClicked(int index) { wxIMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl); -wxRadioBox::wxRadioBox() +wxRadioBox::wxRadioBox() : + m_qtGroupBox(NULL), + m_qtButtonGroup(NULL), + m_qtBoxLayout(NULL) { } @@ -149,7 +152,7 @@ bool wxRadioBox::Create(wxWindow *parent, // GetMajorDim() is the number of rows. if ( style & wxRA_SPECIFY_COLS ) m_qtBoxLayout = new QHBoxLayout; - else if ( style & wxRA_SPECIFY_ROWS ) + else m_qtBoxLayout = new QVBoxLayout; AddChoices< QRadioButton >( m_qtButtonGroup, m_qtBoxLayout, n, choices ); @@ -242,6 +245,9 @@ bool wxRadioBox::Show(unsigned int n, bool show) bool wxRadioBox::Show( bool show ) { + if (!m_qtGroupBox) + return false; + if( m_qtGroupBox->isVisible() == show ) { for( unsigned int i = 0; i < GetCount(); ++i ) diff --git a/src/qt/radiobut.cpp b/src/qt/radiobut.cpp index 64e2100cd4..1a389997da 100644 --- a/src/qt/radiobut.cpp +++ b/src/qt/radiobut.cpp @@ -13,7 +13,8 @@ #include -wxRadioButton::wxRadioButton() +wxRadioButton::wxRadioButton() : + m_qtRadioButton(NULL) { } diff --git a/src/qt/scrolbar.cpp b/src/qt/scrolbar.cpp index e848bf2c0c..77939a2765 100644 --- a/src/qt/scrolbar.cpp +++ b/src/qt/scrolbar.cpp @@ -27,7 +27,8 @@ class wxQtScrollBar : public wxQtEventSignalHandler< QScrollBar, wxScrollBar > }; -wxScrollBar::wxScrollBar() +wxScrollBar::wxScrollBar() : + m_qtScrollBar(NULL) { } diff --git a/src/qt/slider.cpp b/src/qt/slider.cpp index 9efc54d529..1b8e1f96a7 100644 --- a/src/qt/slider.cpp +++ b/src/qt/slider.cpp @@ -46,7 +46,8 @@ void wxQtSlider::valueChanged(int position) } -wxSlider::wxSlider() +wxSlider::wxSlider() : + m_qtSlider(NULL) { } diff --git a/src/qt/spinbutt.cpp b/src/qt/spinbutt.cpp index 0fca8ba9e4..688649461c 100644 --- a/src/qt/spinbutt.cpp +++ b/src/qt/spinbutt.cpp @@ -41,7 +41,8 @@ void wxQtSpinButton::valueChanged(int value) } -wxSpinButton::wxSpinButton() +wxSpinButton::wxSpinButton() : + m_qtSpinBox(NULL) { } diff --git a/src/qt/spinctrl.cpp b/src/qt/spinctrl.cpp index e7cdeddff7..1b9cd3d0ea 100644 --- a/src/qt/spinctrl.cpp +++ b/src/qt/spinctrl.cpp @@ -18,7 +18,8 @@ #include template< typename T, typename Widget > -wxSpinCtrlQt< T, Widget >::wxSpinCtrlQt() +wxSpinCtrlQt< T, Widget >::wxSpinCtrlQt() : + m_qtSpinBox(NULL) { } diff --git a/src/qt/statbmp.cpp b/src/qt/statbmp.cpp index b4dbde30f0..d27a57672f 100644 --- a/src/qt/statbmp.cpp +++ b/src/qt/statbmp.cpp @@ -21,7 +21,8 @@ public: }; -wxStaticBitmap::wxStaticBitmap() +wxStaticBitmap::wxStaticBitmap() : + m_qtLabel(NULL) { } diff --git a/src/qt/statbox.cpp b/src/qt/statbox.cpp index 6af3e2ddb6..cfa585caa0 100644 --- a/src/qt/statbox.cpp +++ b/src/qt/statbox.cpp @@ -23,7 +23,8 @@ public: }; -wxStaticBox::wxStaticBox() +wxStaticBox::wxStaticBox() : + m_qtGroupBox(NULL) { } diff --git a/src/qt/statline.cpp b/src/qt/statline.cpp index 444f59c6e7..82e52f01a8 100644 --- a/src/qt/statline.cpp +++ b/src/qt/statline.cpp @@ -12,7 +12,8 @@ #include -wxStaticLine::wxStaticLine() +wxStaticLine::wxStaticLine() : + m_qtFrame(NULL) { } diff --git a/src/qt/stattext.cpp b/src/qt/stattext.cpp index 8e410bfa10..2eb50b5f18 100644 --- a/src/qt/stattext.cpp +++ b/src/qt/stattext.cpp @@ -22,7 +22,8 @@ public: }; -wxStaticText::wxStaticText() +wxStaticText::wxStaticText() : + m_qtLabel(NULL) { } diff --git a/src/qt/statusbar.cpp b/src/qt/statusbar.cpp index 57881f8a6e..8224c80928 100644 --- a/src/qt/statusbar.cpp +++ b/src/qt/statusbar.cpp @@ -105,6 +105,7 @@ void wxStatusBar::Refresh( bool eraseBackground, const wxRect *rect ) void wxStatusBar::Init() { + m_qtStatusBar = NULL; m_qtPanes = NULL; } diff --git a/src/qt/textctrl.cpp b/src/qt/textctrl.cpp index 5ef1bd97ff..c6498a44d7 100644 --- a/src/qt/textctrl.cpp +++ b/src/qt/textctrl.cpp @@ -90,7 +90,9 @@ void wxQtTextEdit::textChanged() } -wxTextCtrl::wxTextCtrl() +wxTextCtrl::wxTextCtrl() : + m_qtLineEdit(NULL), + m_qtTextEdit(NULL) { } From 172a97e4114ec7b1c5f708f6ce099a7d4b189144 Mon Sep 17 00:00:00 2001 From: Graham Dawes Date: Thu, 20 Dec 2018 13:40:18 +0000 Subject: [PATCH 02/10] Erase event now is now sent with a valid event object --- src/qt/window.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/window.cpp b/src/qt/window.cpp index 8342db8c74..f112f3a545 100644 --- a/src/qt/window.cpp +++ b/src/qt/window.cpp @@ -1074,6 +1074,7 @@ bool wxWindowQt::QtHandlePaintEvent ( QWidget *handler, QPaintEvent *event ) dc.SetDeviceClippingRegion( m_updateRegion ); wxEraseEvent erase( GetId(), &dc ); + erase.SetEventObject(this); if ( ProcessWindowEvent(erase) ) { // background erased, don't do it again From 5c3ddb7a7f56e18f890504b46b37addba00c70b2 Mon Sep 17 00:00:00 2001 From: Graham Dawes Date: Thu, 20 Dec 2018 13:41:02 +0000 Subject: [PATCH 03/10] Prevent crash when attempting to clear a DC with not device under wxQT --- src/qt/dc.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index e5405276cd..5cd918ba2c 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -115,14 +115,46 @@ bool wxQtDCImpl::CanGetTextExtent() const void wxQtDCImpl::DoGetSize(int *width, int *height) const { - if (width) *width = m_qtPainter->device()->width(); - if (height) *height = m_qtPainter->device()->height(); + QPaintDevice *pDevice = m_qtPainter->device(); + + int deviceWidth; + int deviceHeight; + + if (pDevice) + { + deviceWidth = pDevice->width(); + deviceHeight = pDevice->height(); + } + else + { + deviceWidth = 0; + deviceHeight = 0; + + } + if (width) *width = deviceWidth; + if (height) *height = deviceHeight; } void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const { - if (width) *width = m_qtPainter->device()->widthMM(); - if (height) *height = m_qtPainter->device()->heightMM(); + QPaintDevice *pDevice = m_qtPainter->device(); + + int deviceWidthMM; + int deviceHeightMM; + + if (pDevice) + { + deviceWidthMM = pDevice->widthMM(); + deviceHeightMM = pDevice->heightMM(); + } + else + { + deviceWidthMM = 0; + deviceHeightMM = 0; + } + + if (width) *width = deviceWidthMM; + if (height) *height = deviceHeightMM; } int wxQtDCImpl::GetDepth() const From c7425b8c6447799054c54723ee372d5fdcec3e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 13:59:11 +0000 Subject: [PATCH 04/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 5cd918ba2c..22e164613e 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -120,7 +120,7 @@ void wxQtDCImpl::DoGetSize(int *width, int *height) const int deviceWidth; int deviceHeight; - if (pDevice) + if ( pDevice ) { deviceWidth = pDevice->width(); deviceHeight = pDevice->height(); From ae825ecd8667131bd6cfc26a38c0990f3ab241db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 13:59:18 +0000 Subject: [PATCH 05/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 22e164613e..8221f6ba21 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -132,7 +132,8 @@ void wxQtDCImpl::DoGetSize(int *width, int *height) const } if (width) *width = deviceWidth; - if (height) *height = deviceHeight; + if ( height ) + *height = deviceHeight; } void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const From 8f5acb341eeee5d27eb6921e26d7ce04aa0cdea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 13:59:24 +0000 Subject: [PATCH 06/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 8221f6ba21..fc0db374aa 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -154,7 +154,8 @@ void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const deviceHeightMM = 0; } - if (width) *width = deviceWidthMM; + if ( width ) + *width = deviceWidthMM; if (height) *height = deviceHeightMM; } From f8110c1c2737ec3656d62ce8d47c231c206472cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 13:59:31 +0000 Subject: [PATCH 07/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index fc0db374aa..70b69bbb9b 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -156,7 +156,8 @@ void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const if ( width ) *width = deviceWidthMM; - if (height) *height = deviceHeightMM; + if ( height ) + *height = deviceHeightMM; } int wxQtDCImpl::GetDepth() const From 90165488f63a204d33490940d2602c41c6593926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 13:59:49 +0000 Subject: [PATCH 08/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 70b69bbb9b..6c3e940bb6 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -131,7 +131,8 @@ void wxQtDCImpl::DoGetSize(int *width, int *height) const deviceHeight = 0; } - if (width) *width = deviceWidth; + if ( width ) + *width = deviceWidth; if ( height ) *height = deviceHeight; } From f0df737326c253e885aa3754a5955a4bc23fcc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83t=C4=83lin=20R=C4=83ceanu?= Date: Thu, 20 Dec 2018 14:00:03 +0000 Subject: [PATCH 09/10] Update src/qt/dc.cpp Co-Authored-By: ffa-grahamdawes --- src/qt/dc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qt/dc.cpp b/src/qt/dc.cpp index 6c3e940bb6..2ccb0906ab 100644 --- a/src/qt/dc.cpp +++ b/src/qt/dc.cpp @@ -144,7 +144,7 @@ void wxQtDCImpl::DoGetSizeMM(int* width, int* height) const int deviceWidthMM; int deviceHeightMM; - if (pDevice) + if ( pDevice ) { deviceWidthMM = pDevice->widthMM(); deviceHeightMM = pDevice->heightMM(); From b890f59bc95c42d2b78803aea1a2aa86ca1e171f Mon Sep 17 00:00:00 2001 From: Graham Dawes Date: Fri, 21 Dec 2018 08:18:17 +0000 Subject: [PATCH 10/10] Call base class Show from wxRadioBox::Show --- src/qt/radiobox.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qt/radiobox.cpp b/src/qt/radiobox.cpp index 22706e8038..58b88b8989 100644 --- a/src/qt/radiobox.cpp +++ b/src/qt/radiobox.cpp @@ -245,6 +245,9 @@ bool wxRadioBox::Show(unsigned int n, bool show) bool wxRadioBox::Show( bool show ) { + if ( !wxControl::Show(show) ) + return false; + if (!m_qtGroupBox) return false;