Fix possible crash in ElasticScroll destructor.
This commit is contained in:
parent
0999c7f70e
commit
fa8de8b199
2 changed files with 13 additions and 2 deletions
|
|
@ -381,6 +381,14 @@ ElasticScroll::ElasticScroll(
|
||||||
}, _bar->lifetime());
|
}, _bar->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ElasticScroll::~ElasticScroll() {
|
||||||
|
// Destroy the _bar cleanly (keeping _bar == nullptr) to avoid a crash:
|
||||||
|
//
|
||||||
|
// _bar destructor may send LeaveEvent to ElasticScroll,
|
||||||
|
// which will try to toggle(false) the _bar in leaveEventHook.
|
||||||
|
base::take(_bar);
|
||||||
|
}
|
||||||
|
|
||||||
void ElasticScroll::setHandleTouch(bool handle) {
|
void ElasticScroll::setHandleTouch(bool handle) {
|
||||||
if (_touchDisabled != handle) {
|
if (_touchDisabled != handle) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -1071,14 +1079,16 @@ void ElasticScroll::keyPressEvent(QKeyEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticScroll::enterEventHook(QEnterEvent *e) {
|
void ElasticScroll::enterEventHook(QEnterEvent *e) {
|
||||||
if (!_disabled) {
|
if (_bar && !_disabled) {
|
||||||
_bar->toggle(true);
|
_bar->toggle(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticScroll::leaveEventHook(QEvent *e) {
|
void ElasticScroll::leaveEventHook(QEvent *e) {
|
||||||
|
if (_bar) {
|
||||||
_bar->toggle(false);
|
_bar->toggle(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ElasticScroll::scrollTo(ScrollToRequest request) {
|
void ElasticScroll::scrollTo(ScrollToRequest request) {
|
||||||
scrollToY(request.ymin, request.ymax);
|
scrollToY(request.ymin, request.ymax);
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,7 @@ public:
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const style::ScrollArea &st = st::defaultScrollArea,
|
const style::ScrollArea &st = st::defaultScrollArea,
|
||||||
Qt::Orientation orientation = Qt::Vertical);
|
Qt::Orientation orientation = Qt::Vertical);
|
||||||
|
~ElasticScroll();
|
||||||
|
|
||||||
void setHandleTouch(bool handle);
|
void setHandleTouch(bool handle);
|
||||||
bool viewportEvent(QEvent *e);
|
bool viewportEvent(QEvent *e);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue