Figure out segfault

This commit is contained in:
johanneshilden 2017-10-13 22:37:05 +03:00
parent 696dc2ed2a
commit 8a64b5a981
3 changed files with 35 additions and 11 deletions

View File

@ -21,24 +21,24 @@ QtMaterialRippleOverlay::~QtMaterialRippleOverlay()
void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple) void QtMaterialRippleOverlay::addRipple(QtMaterialRipple *ripple)
{ {
ripple->setOverlay(this); //ripple->setOverlay(this);
m_ripples.push_back(ripple); //m_ripples.push_back(ripple);
ripple->start(); //ripple->start();
} }
void QtMaterialRippleOverlay::addRipple(const QPoint &position, qreal radius) void QtMaterialRippleOverlay::addRipple(const QPoint &position, qreal radius)
{ {
QtMaterialRipple *ripple = new QtMaterialRipple(position); //QtMaterialRipple *ripple = new QtMaterialRipple(position);
ripple->setRadiusEndValue(radius); //ripple->setRadiusEndValue(radius);
addRipple(ripple); //addRipple(ripple);
} }
void QtMaterialRippleOverlay::removeRipple(QtMaterialRipple *ripple) void QtMaterialRippleOverlay::removeRipple(QtMaterialRipple *ripple)
{ {
if (m_ripples.removeOne(ripple)) { //if (m_ripples.removeOne(ripple)) {
delete ripple; // delete ripple;
update(); // update();
} //}
} }
/*! /*!

View File

@ -3,6 +3,7 @@
#include <QtWidgets/QGraphicsDropShadowEffect> #include <QtWidgets/QGraphicsDropShadowEffect>
#include <QtWidgets/QVBoxLayout> #include <QtWidgets/QVBoxLayout>
#include <QEvent> #include <QEvent>
#include <QDebug>
#include "qtmaterialflatbutton.h" #include "qtmaterialflatbutton.h"
/*! /*!
@ -104,13 +105,18 @@ void QtMaterialAutoComplete::updateResults(QString text)
item->setHaloVisible(false); item->setHaloVisible(false);
item->setFixedHeight(50); item->setFixedHeight(50);
d->menuLayout->addWidget(item); d->menuLayout->addWidget(item);
//item->installEventFilter(this);
} }
} else if (diff < 0) { } else if (diff < 0) {
for (int c = 0; c < -diff; c++) { for (int c = 0; c < -diff; c++) {
QWidget *widget = d->menuLayout->itemAt(0)->widget(); QWidget *widget = d->menuLayout->itemAt(0)->widget();
if (widget) { if (widget) {
d->menuLayout->removeWidget(widget); d->menuLayout->removeWidget(widget);
delete widget; //widget->setParent(0);
//qDebug() << widget->parent();
//qDebug() << widget->parentWidget();
//delete widget;
widget->deleteLater();
} }
} }
} }
@ -163,3 +169,20 @@ bool QtMaterialAutoComplete::QtMaterialAutoComplete::event(QEvent *event)
} }
return QtMaterialTextField::event(event); return QtMaterialTextField::event(event);
} }
bool QtMaterialAutoComplete::eventFilter(QObject *watched, QEvent *event)
{
Q_D(QtMaterialAutoComplete);
switch (event->type())
{
case QEvent::MouseButtonPress: {
qDebug() << "mouse pressl";
d->menu->hide();
break;
}
default:
break;
}
return QtMaterialTextField::eventFilter(watched, event);
}

View File

@ -20,6 +20,7 @@ protected slots:
protected: protected:
bool event(QEvent *event) Q_DECL_OVERRIDE; bool event(QEvent *event) Q_DECL_OVERRIDE;
bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(QtMaterialAutoComplete) Q_DISABLE_COPY(QtMaterialAutoComplete)