QScroller crash after deleting QListWidget on Android
-
To test QScroller on my Android device,
I have written a simple HelloWorld-like application with QStackedWidget with 2 pages.
Every page has a single QListWidget with a number of items.
On startup, the app shows page_2 of the stacked widget with a number of items. QScroller is attached programmatically to this QListWidget:MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);ui->stackedWidget->setCurrentIndex(1); scroller = QScroller::scroller(ui->listWidget_2); scroller->grabGesture(ui->listWidget_2);
}
On application startup everything is ok. QScroller attached is working fine with the QListWidget.
After that I press "Go to page 1" button which removes the entire page from the stacked widget and attach QScroller to the second QListWidget :
void MainWindow::on_pushButton_clicked()
{
QScroller::ungrabGesture(ui->listWidget_2);ui->stackedWidget->removeWidget(ui->page_2); ui->page_2->deleteLater(); ui->page_2 = nullptr; QScroller* scroller2 = QScroller::scroller(ui->listWidget); scroller2->grabGesture(ui->listWidget);
}
The widget is displayed OK. But when I try to scroll it with my fingers, the app crashes with SIGSEGV(Segmentation fault) and the stack is:
#10 qtMainLoopThread
- QWidget* object_cast<QWidget*>(QObject*)
- QFlickGestureRecognizer::recognize(QGesture*, QObject*, QEvent*)
- ???
What am i doing wrong???
The complete source code of the application:
https://yadi.sk/d/hothr7gx3YpG2A