Merge pull request #920 from xiaoyifang/fix/status-2

fix: possible crash when show()
This commit is contained in:
xiaoyifang 2023-07-02 10:00:45 +08:00 committed by GitHub
commit 759246a86f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -26,7 +26,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent )
timer->setSingleShot( true );
// layout
QHBoxLayout * layout = new QHBoxLayout;
const auto layout = new QHBoxLayout;
layout->setSpacing( 0 );
layout->setSizeConstraint( QLayout::SetFixedSize );
layout->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
@ -40,9 +40,6 @@ 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()
@ -51,7 +48,6 @@ void MainStatusBar::clearMessage()
textWidget->setText( backgroungMessage );
picWidget->setPixmap( QPixmap() );
timer->stop();
hide();
}
QString MainStatusBar::currentMessage() const
@ -65,8 +61,6 @@ void MainStatusBar::setBackgroundMessage(const QString & bkg_message )
if( message.isEmpty() )
{
textWidget->setText( backgroungMessage );
raise();
show();
}
}
@ -85,8 +79,10 @@ void MainStatusBar::showMessage( const QString & str, int timeout, const QPixmap
if ( timeout > 0 ) {
timer->start( timeout );
}
raise();
show();
if ( parentWidget() ) {
move( 0, parentWidget()->height() - height() );
}
}
void MainStatusBar::mousePressEvent ( QMouseEvent * )