- 
    
Bug
 - 
    Resolution: Done
 - 
    
P2: Important
 - 
    5.15.8, 5.15.10, 6.4.0 FF
 
- 
        
 - 
        2ed54dedf3 (qt/qtbase/dev) 2ed54dedf3 (qt/tqtc-qtbase/dev) 1ed89b7012 (qt/qtbase/6.4) 1ed89b7012 (qt/tqtc-qtbase/6.4) 53e3c7ed9f (qt/qtbase/6.3) 53e3c7ed9f (qt/tqtc-qtbase/6.3) 5b409aa872 (qt/tqtc-qtbase/6.2) da4f2177f8 (qt/tqtc-qtbase/5.15)
 
After QMainWindow::restoreState() is called the widgetItem is set to nullptr for the toolbar. Which can lead to crash in some situation.
When looking into more deeper, A toolbar knows the layout item (it is a QWidgetItemV2 instance) which are wrapped in (via QWidgetPrivate::widgetItem) But after QMainWindow::restoreState the widgetItem is set to nullptr for the toolbar, although there is a new layout item containing it.
I attached a small program to reproduce the problem. It logs Null pointer after restoreState.
| For Gerrit Dashboard: QTBUG-102395 | ||||||
|---|---|---|---|---|---|---|
| # | Subject | Branch | Project | Status | CR | V | 
| 416749,3 | QMainWindow: fix restoreState() for toolbars | dev | qt/qtbase | Status: MERGED | +2 | 0 | 
| 417071,2 | QMainWindow: fix restoreState() for toolbars | 6.4 | qt/qtbase | Status: MERGED | +2 | 0 | 
| 417072,2 | QMainWindow: fix restoreState() for toolbars | 6.3 | qt/qtbase | Status: MERGED | +2 | 0 | 
| 417097,2 | QMainWindow: fix restoreState() for toolbars | tqtc/lts-6.2 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 | 
| 417098,2 | QMainWindow: fix restoreState() for toolbars | tqtc/lts-5.15 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |