From 666fda707688a305a0ca16a698868e6983824803 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 11 Mar 2003 11:25:08 +0000 Subject: weak ref the dialog (from galeon) 2003-03-11 Marco Pesenti Gritti * embed/mozilla/ProgressListener.cpp: weak ref the dialog (from galeon) --- embed/mozilla/ProgressListener.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'embed/mozilla') diff --git a/embed/mozilla/ProgressListener.cpp b/embed/mozilla/ProgressListener.cpp index 039e9af40..bfd6c7d7d 100644 --- a/embed/mozilla/ProgressListener.cpp +++ b/embed/mozilla/ProgressListener.cpp @@ -64,7 +64,11 @@ GProgressListener::GProgressListener () : mLauncher(nsnull), GProgressListener::~GProgressListener () { - /* destructor code */ + if (mDownloaderView) + { + g_object_remove_weak_pointer (G_OBJECT (mDownloaderView), + (void **) &mDownloaderView); + } } NS_METHOD GProgressListener::InitForPersist (nsIWebBrowserPersist *aPersist, @@ -149,7 +153,7 @@ NS_METHOD GProgressListener::PrivateInit (void) mElapsed = now - mStartTime; - if (!mNoDialog) + if (!mNoDialog && mDownloaderView) { gchar *filename, *source, *dest; nsAutoString uTmp; @@ -179,6 +183,9 @@ NS_METHOD GProgressListener::PrivateInit (void) G_CALLBACK (download_resume_cb), this); mDownloaderView = dv; + + g_object_add_weak_pointer (G_OBJECT (mDownloaderView), + (void **) &mDownloaderView); } /* done */ @@ -513,15 +520,18 @@ NS_IMETHODIMP GProgressListener:: /currentRate +.5); } - downloader_view_set_download_progress (mDownloaderView, - mElapsed, - remaining, - speed, - totalKBytes, - currentKBytes, - progress, - mCanPause, - (gpointer)this); + if (mDownloaderView) + { + downloader_view_set_download_progress (mDownloaderView, + mElapsed, + remaining, + speed, + totalKBytes, + currentKBytes, + progress, + mCanPause, + (gpointer)this); + } /* done */ return NS_OK; -- cgit v1.2.3