fix: statusbar at some rare conditions crash

the stacktrace show the line is parentWidget().
avoid using this the parentWidget() method.
This commit is contained in:
YiFang Xiao 2023-07-01 22:33:58 +08:00
parent 6deb38be7b
commit ed8072d78f

View file

@ -40,6 +40,9 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
connect( timer, &QTimer::timeout, this, &MainStatusBar::clearMessage );
setAutoFillBackground( true );
if ( parent )
move( 0, parent->height() - height() );
}
void MainStatusBar::clearMessage()
@ -72,24 +75,18 @@ void MainStatusBar::showMessage(const QString & str, int timeout, const QPixmap
textWidget->setText( message = str );
picWidget->setPixmap( pixmap );
if ( !picWidget->pixmap().isNull() )
{
if ( !picWidget->pixmap().isNull() ) {
picWidget->setFixedSize( textWidget->height(), textWidget->height() );
}
else
{
else {
picWidget->setFixedSize( 0, 0 );
}
if ( timeout > 0 )
{
if ( timeout > 0 ) {
timer->start( timeout );
}
if ( parentWidget() && parentWidget()->isVisible() ) {
raise();
show();
move( QPoint( 0, parentWidget()->height() - height() ) );
}
}
void MainStatusBar::mousePressEvent ( QMouseEvent * )