tdeio: only create the internal guarded pointer for TDEIO::Job if it is really required. This fix avoid creation and destruction of unnecessary TQObjects and helps speeding up operations which requires lot of Jobs.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/192/head
Michele Calgaro 2 years ago
parent 4d90cc6117
commit ea10b6290d
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -89,15 +89,23 @@ template class TQPtrList<TDEIO::Job>;
class Job::JobPrivate
{
public:
JobPrivate() : m_autoErrorHandling( false ), m_autoWarningHandling( true ),
m_interactive( true ), m_parentJob( 0L ), m_extraFlags(0),
m_processedSize(0), m_userTimestamp(0)
JobPrivate() : m_autoErrorHandling(false), m_autoWarningHandling(true),
m_interactive(true), m_errorParentWidgetGP(0), m_parentJob(0L),
m_extraFlags(0), m_processedSize(0), m_userTimestamp(0)
{}
~JobPrivate()
{
if (m_errorParentWidgetGP)
{
delete m_errorParentWidgetGP;
}
}
bool m_autoErrorHandling;
bool m_autoWarningHandling;
bool m_interactive;
TQGuardedPtr<TQWidget> m_errorParentWidget;
TQGuardedPtr<TQWidget> *m_errorParentWidgetGP;
// Maybe we could use the TQObject parent/child mechanism instead
// (requires a new ctor, and moving the ctor code to some init()).
Job* m_parentJob;
@ -143,7 +151,9 @@ Job::~Job()
delete m_speedTimer;
delete d;
if (kapp)
kapp->deref();
{
kapp->deref();
}
}
int& Job::extraFlags()
@ -233,7 +243,7 @@ void Job::emitResult()
if ( m_progressId ) // Did we get an ID from the observer ?
Observer::self()->jobFinished( m_progressId );
if ( m_error && d->m_interactive && d->m_autoErrorHandling )
showErrorDialog( d->m_errorParentWidget );
showErrorDialog( d->m_errorParentWidgetGP ? *d->m_errorParentWidgetGP : nullptr);
emit result(this);
deleteLater();
}
@ -322,8 +332,16 @@ void Job::showErrorDialog( TQWidget * parent )
void Job::setAutoErrorHandlingEnabled( bool enable, TQWidget *parentWidget )
{
if (d->m_errorParentWidgetGP && (TQWidget*)(*d->m_errorParentWidgetGP) != parentWidget)
{
delete d->m_errorParentWidgetGP;
d->m_errorParentWidgetGP = nullptr;
}
d->m_autoErrorHandling = enable;
d->m_errorParentWidget = parentWidget;
if (enable && parentWidget && !d->m_errorParentWidgetGP)
{
d->m_errorParentWidgetGP = new TQGuardedPtr<TQWidget>(parentWidget);
}
}
bool Job::isAutoErrorHandlingEnabled() const

Loading…
Cancel
Save