diff options
-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 |