diff options
| author | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-02-14 12:19:56 +0900 | 
|---|---|---|
| committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2023-02-14 12:22:23 +0900 | 
| commit | ea10b6290dd14c79fd3192a2f772093310b94f22 (patch) | |
| tree | 808c9ea2a613c98068bcaa83c6e2143309295958 | |
| parent | 4d90cc6117564d8aab9be1b65593161252f0298a (diff) | |
| download | tdelibs-ea10b629.tar.gz tdelibs-ea10b629.zip | |
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>
| -rw-r--r-- | tdeio/tdeio/job.cpp | 32 | 
1 files changed, 25 insertions, 7 deletions
| diff --git a/tdeio/tdeio/job.cpp b/tdeio/tdeio/job.cpp index 2c17d8534..43b0c808b 100644 --- a/tdeio/tdeio/job.cpp +++ b/tdeio/tdeio/job.cpp @@ -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 | 
