Fix #895 by adapting to Qt5 and cleaning up properly

Relevant Qt commit:
https://codereview.qt-project.org/#/c/72637/
"QProgressDialog: don't require setValue(0) to be called."

"Fixed by starting the timer in the constructor (most code doesn't reuse
progress dialogs, so this fixes the most common case)"

This messes us up because we're (ab-)using the dialog
in a non-standard way.

https://bugreports.qt.io/browse/QTBUG-47042
"QProgressDialog is designed to show itself automatically, based
on an internal estimate for the duration of the operation and the
minimumDuration property. You never call show() or exec() on it
manually. You're also not supposed to keep it around when it's not
used. In 5.4, the only way to start the internal duration estimation
was to call setValue(0). But we noticed that many people didn't call
setValue(0)"

Workaround here:
https://bugreports.qt.io/browse/QTBUG-47042

"As a workaround I added the line m_progressDlg->reset(); in the main
window constructor in order to get the same behavior as in former
versions."
This commit is contained in:
Soeren Apel 2017-05-24 23:50:37 +02:00
parent e0ddc2a408
commit f7449c5067
1 changed files with 19 additions and 0 deletions

View File

@ -48,6 +48,19 @@ StoreProgress::StoreProgress(const QString &file_name,
this, SLOT(on_progress_updated()));
connect(&session_, SIGNAL(store_successful()),
&session, SLOT(on_data_saved()));
// Since we're not setting any progress in case of an error, the dialog
// will pop up after the minimumDuration time has been reached - 4000 ms
// by default.
// We do not want this as it overlaps with the error message box, so we
// set the minimumDuration to 0 so that it only appears when we feed it
// progress data. Then, call reset() to prevent the progress dialog from
// popping up anyway. This would happen in Qt5 because the behavior was
// changed in such a way that the duration timer is started by the
// constructor. We don't want that and reset() stops the timer, so we
// use it.
setMinimumDuration(0);
reset();
}
StoreProgress::~StoreProgress()
@ -71,11 +84,17 @@ void StoreProgress::show_error()
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
close();
}
void StoreProgress::closeEvent(QCloseEvent*)
{
session_.cancel();
// Closing doesn't mean we're going to be destroyed because our parent
// still owns our handle. Make sure this stale instance doesn't hang around.
deleteLater();
}
void StoreProgress::on_progress_updated()