mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Do not attempt to show detailed tooltips without torrent metadata. Closes #6768.
Computations for detailed tooltips are not protected against unavailable metadata, that leads to asserts or crashes. But since those tooltips are useless in this case, do not show them at all. Inform user that detailed tooltip becomes available once torrent metadata are fetched.
This commit is contained in:
parent
d61fc7e820
commit
f211b238c4
1 changed files with 7 additions and 4 deletions
|
@ -251,8 +251,8 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||||
|
|
||||||
QString toolTipText;
|
QString toolTipText;
|
||||||
QTextStream stream(&toolTipText, QIODevice::WriteOnly);
|
QTextStream stream(&toolTipText, QIODevice::WriteOnly);
|
||||||
bool showDetailedInformation = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
const bool showDetailedInformation = QApplication::keyboardModifiers().testFlag(Qt::ShiftModifier);
|
||||||
if (showDetailedInformation) {
|
if (showDetailedInformation && m_torrent->hasMetadata()) {
|
||||||
const int imagePos = e->pos().x() - borderWidth;
|
const int imagePos = e->pos().x() - borderWidth;
|
||||||
if ((imagePos >=0) && (imagePos < m_image.width())) {
|
if ((imagePos >=0) && (imagePos < m_image.width())) {
|
||||||
stream << "<html><body>";
|
stream << "<html><body>";
|
||||||
|
@ -286,6 +286,9 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stream << simpleToolTipText();
|
stream << simpleToolTipText();
|
||||||
|
if (showDetailedInformation) // metadata are not available at this point
|
||||||
|
stream << '\n' << tr("Wait until metadata become available to see detailed information");
|
||||||
|
else
|
||||||
stream << '\n' << tr("Hold Shift key for detailed information");
|
stream << '\n' << tr("Hold Shift key for detailed information");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +299,7 @@ void PiecesBar::showToolTip(const QHelpEvent *e)
|
||||||
|
|
||||||
void PiecesBar::highlightFile(int imagePos)
|
void PiecesBar::highlightFile(int imagePos)
|
||||||
{
|
{
|
||||||
if (!m_torrent || (imagePos < 0) || (imagePos >= m_image.width()))
|
if (!m_torrent || !m_torrent->hasMetadata() || (imagePos < 0) || (imagePos >= m_image.width()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PieceIndexToImagePos transform {m_torrent->info(), m_image};
|
PieceIndexToImagePos transform {m_torrent->info(), m_image};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue