1
From: Matthias Fuchs <mat69@gmx.net>
2
Date: Thu, 07 Apr 2011 13:32:26 +0000
3
Subject: Fixes prefetching. Now constant useage of the comic applet does not lead to high memory usage.
4
X-Git-Url: http://quickgit.kde.org/?p=kdeplasma-addons.git&a=commitdiff&h=4ab9e40e1e3484a4adf059164c91e06d1f5b6b76
6
Fixes prefetching. Now constant useage of the comic applet does not lead to high memory usage.
11
Index: kdeplasma-addons-4.6.2/applets/comic/comic.cpp
12
===================================================================
13
--- kdeplasma-addons-4.6.2.orig/applets/comic/comic.cpp 2011-04-10 10:40:19.520167015 +0200
14
+++ kdeplasma-addons-4.6.2/applets/comic/comic.cpp 2011-04-10 10:40:24.340167016 +0200
19
-void ComicApplet::dataUpdated( const QString&, const Plasma::DataEngine::Data &data )
20
+void ComicApplet::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data )
22
+ //disconnect prefetched comic strips
23
+ if ( source != mOldSource ) {
24
+ mEngine->disconnectSource( source, this );
29
setConfigurationRequired( false );
32
//there was an error, display information as image
33
- if ( data[ "Error" ].toBool() ) {
34
- if ( !mShowErrorPicture && !data[ "Previous identifier suffix" ].toString().isEmpty() ) {
35
- updateComic( data[ "Previous identifier suffix" ].toString() );
36
+ const bool hasError = data[ "Error" ].toBool();
37
+ const bool errorAutoFixable = data[ "Error automatically fixable" ].toBool();
39
+ const QString previousIdentifierSuffix = data[ "Previous identifier suffix" ].toString();
40
+ if ( !mShowErrorPicture && !previousIdentifierSuffix.isEmpty() ) {
41
+ mEngine->disconnectSource( source, this );
42
+ updateComic( previousIdentifierSuffix );
45
QPixmap errorPic( 500, 400 );
47
mLabelUrl->setText( mWebsiteUrl.host() );
48
mImageWidget->setScaled( !mScaleComic );
50
+ //disconnect if there is either no error, or an error that can not be fixed automatically
51
+ if ( !errorAutoFixable ) {
52
+ mEngine->disconnectSource( source, this );
55
setTabBarVisible( mShowTabBar && mUseTabs );
56
mLabelTop->setVisible( ( mShowComicAuthor || mShowComicTitle ) && !mLabelTop->text().isEmpty() );
57
mLabelId->setVisible( mShowComicIdentifier && !mLabelId->text().isEmpty() );
60
//prefetch the previous and following comic for faster navigation
61
if ( !mNextIdentifierSuffix.isEmpty() ) {
62
- mEngine->query( mComicIdentifier + ':' + mNextIdentifierSuffix );
63
+ const QString prefetch = mComicIdentifier + ':' + mNextIdentifierSuffix;
64
+ mEngine->connectSource( prefetch, this );
65
+ mEngine->query( prefetch );
68
if ( !mPreviousIdentifierSuffix.isEmpty() ) {
69
- mEngine->query( mComicIdentifier + ':' + mPreviousIdentifierSuffix );
70
+ const QString prefetch = mComicIdentifier + ':' + mPreviousIdentifierSuffix;
71
+ mEngine->connectSource( prefetch, this );
72
+ mEngine->query( prefetch );
78
setConfigurationRequired( mComicIdentifier.isEmpty() );
79
if ( !mComicIdentifier.isEmpty() && mEngine && mEngine->isValid() ) {
82
const QString identifier = mComicIdentifier + ':' + identifierSuffix;
84
Index: kdeplasma-addons-4.6.2/dataengines/comic/comic.cpp
85
===================================================================
86
--- kdeplasma-addons-4.6.2.orig/dataengines/comic/comic.cpp 2011-04-10 10:40:19.530167015 +0200
87
+++ kdeplasma-addons-4.6.2/dataengines/comic/comic.cpp 2011-04-10 10:40:24.340167016 +0200
89
if ( status != Solid::Networking::Connected && status != Solid::Networking::Unknown ) {
90
mIdentifierError = identifier;
91
setData( identifier, QLatin1String( "Error" ), true );
92
+ setData( identifier, QLatin1String( "Error automatically fixable" ), true );
93
setData( identifier, QLatin1String( "Identifier" ), identifier );
94
setData( identifier, QLatin1String( "Previous identifier suffix" ), lastCachedIdentifier( identifier ) );
95
kWarning() << "No connection.";