[Korganizer-devel] [Bug 258560] kontact crash alone, after a certain time
Sergio Martins
iamsergio at gmail.com
Fri Dec 31 01:52:59 CET 2010
https://bugs.kde.org/show_bug.cgi?id=258560
Sergio Martins <iamsergio at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Sergio Martins <iamsergio gmail com> 2010-12-31 01:52:57 ---
commit 87b008b02edeab2ae50944eb29efe78e13e49c9d
branch master
Author: Sergio Martins <iamsergio at gmail.com>
Date: Fri Dec 31 00:49:10 2010 +0000
Not a good idea to pass a local variable reference to a class with async
API.
When the job finishes, the variable is already scoped out and destroyed.
Fixes crash in HTML exporting.
BUG: 258560
diff --git a/korganizer/actionmanager.cpp b/korganizer/actionmanager.cpp
index ab56443..fc2bd8d 100644
--- a/korganizer/actionmanager.cpp
+++ b/korganizer/actionmanager.cpp
@@ -40,7 +40,6 @@
#include "kowindowlist.h"
#include "reminderclient.h"
#include "akonadicollectionview.h"
-#include "htmlexportjob.h"
#include "htmlexportsettings.h"
#include <KCalCore/FileStorage>
@@ -1180,27 +1179,28 @@ bool ActionManager::saveURL()
void ActionManager::exportHTML()
{
- HTMLExportSettings settings( "KOrganizer" );
+ HTMLExportSettingsPtr settings( new HTMLExportSettings( "KOrganizer" ) );
// Manually read in the config, because parametrized kconfigxt objects don't
// seem to load the config theirselves
- settings.readConfig();
+ settings->readConfig();
const QDate qd1 = QDate::currentDate();
QDate qd2 = qd1;
- if ( settings.monthView() ) {
+ if ( settings->monthView() ) {
qd2.addMonths( 1 );
} else {
qd2.addDays( 7 );
}
- settings.setDateStart( QDateTime( qd1 ) );
- settings.setDateEnd( QDateTime( qd2 ) );
- exportHTML( &settings );
+ settings->setDateStart( QDateTime( qd1 ) );
+ settings->setDateEnd( QDateTime( qd2 ) );
+ exportHTML( settings );
}
-void ActionManager::exportHTML( KOrg::HTMLExportSettings *settings )
+void ActionManager::exportHTML( const KOrg::HTMLExportSettingsPtr &settings )
{
if ( !settings || settings->outputFile().isEmpty() ) {
+ kWarning() << "Settings is null, or the output file is empty " <<
settings.data();
return;
}
diff --git a/korganizer/actionmanager.h b/korganizer/actionmanager.h
index 0bc744f..07a7812 100644
--- a/korganizer/actionmanager.h
+++ b/korganizer/actionmanager.h
@@ -30,6 +30,7 @@
#include "korganizer_export.h"
#include "korganizer/part.h"
+#include "htmlexportjob.h"
#include <KCalCore/Incidence>
@@ -127,7 +128,7 @@ class KORGANIZERPRIVATE_EXPORT ActionManager : public
QObject
bool saveAsURL( const KUrl &kurl );
void exportHTML();
- void exportHTML( KOrg::HTMLExportSettings * );
+ void exportHTML( const KOrg::HTMLExportSettingsPtr & );
void toggleMenubar( bool dontShowWarning = false );
public:
diff --git a/korganizer/htmlexportjob.cpp b/korganizer/htmlexportjob.cpp
index a599337..54e574e 100644
--- a/korganizer/htmlexportjob.cpp
+++ b/korganizer/htmlexportjob.cpp
@@ -54,11 +54,12 @@ using namespace KOrg;
static QString cleanChars( const QString &txt );
+
//@cond PRIVATE
class KOrg::HtmlExportJob::Private
{
public:
- Private( CalendarSupport::Calendar *calendar, KOrg::HTMLExportSettings
*settings, QWidget *parent )
+ Private( CalendarSupport::Calendar *calendar, const HTMLExportSettingsPtr
&settings, QWidget *parent )
: mCalendar( calendar ),
mSettings( settings ),
mParentWidget( parent ),
@@ -66,7 +67,7 @@ class KOrg::HtmlExportJob::Private
{}
CalendarSupport::Calendar *mCalendar;
- KOrg::HTMLExportSettings *mSettings;
+ HTMLExportSettingsPtr mSettings;
QWidget *mParentWidget;
QMap<QDate,QString> mHolidayMap;
qulonglong mSubJobCount;
@@ -74,7 +75,7 @@ class KOrg::HtmlExportJob::Private
};
//@endcond
-HtmlExportJob::HtmlExportJob( CalendarSupport::Calendar *calendar,
KOrg::HTMLExportSettings *settings, QWidget *parent )
+HtmlExportJob::HtmlExportJob( CalendarSupport::Calendar *calendar, const
HTMLExportSettingsPtr &settings, QWidget *parent )
: KJob( parent ), d( new Private( calendar, settings, parent ) )
{
}
diff --git a/korganizer/htmlexportjob.h b/korganizer/htmlexportjob.h
index a7927ca..aeb5aa9 100644
--- a/korganizer/htmlexportjob.h
+++ b/korganizer/htmlexportjob.h
@@ -24,13 +24,14 @@
#include <kjob.h>
-#include <kcalcore/incidence.h>
-#include <kcalcore/event.h>
-#include <kcalcore/todo.h>
+#include <KCalCore/Incidence>
+#include <KCalCore/Event>
+#include <KCalCore/Todo>
#include <QtCore/QDateTime>
#include <QtCore/QString>
#include <QtCore/QTextStream>
+#include <QSharedPointer>
class QTextStream;
@@ -42,9 +43,10 @@ namespace CalendarSupport {
class Calendar;
}
-namespace KOrg {
+namespace KOrg {
class HTMLExportSettings;
+typedef QSharedPointer<HTMLExportSettings> HTMLExportSettingsPtr;
/**
This class provides the functions to export a calendar as a HTML page.
@@ -57,7 +59,8 @@ class HtmlExportJob : public KJob
/**
Create new HTML exporter for calendar.
*/
- HtmlExportJob( CalendarSupport::Calendar *calendar, HTMLExportSettings
*settings, QWidget *parent = 0 );
+ HtmlExportJob( CalendarSupport::Calendar *calendar, const
HTMLExportSettingsPtr &settings,
+ QWidget *parent = 0 );
virtual ~HtmlExportJob();
void addHoliday( const QDate &date, const QString &name );
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Korganizer-devel
mailing list