[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdepim/KDE/4.8] akregator/src: in doCreate(), when the akregator part hasn't been loaded yet someti
From:       Allen Winter <winter () kde ! org>
Date:       2012-02-01 0:07:11
Message-ID: 20120201000711.80B36A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit 4d661ef66b4eb4b320ce6ee2fb91bf3818c25e20 by Allen Winter.
Committed on 01/02/2012 at 01:01.
Pushed by winterz into branch 'KDE/4.8'.

in doCreate(), when the akregator part hasn't been loaded yet sometimes
the parent and root folders aren't set, in this case set the root folder
to the "All" Folders top-level and add the new feed there.

I found this crash while testing out another bug, so I don't know if
this fixes any reported crashes -- certainly wouldn't surprise me.

MERGE: 4.8
(cherry picked from commit a19ca446ebeead28a8f44cbedfc6d36953408ab3)

M  +18   -5    akregator/src/createfeedcommand.cpp
M  +4    -3    akregator/src/createfeedcommand.h
M  +5    -0    akregator/src/mainwidget.h

http://commits.kde.org/kdepim/4d661ef66b4eb4b320ce6ee2fb91bf3818c25e20

diff --git a/akregator/src/createfeedcommand.cpp b/akregator/src/createfeedcommand.cpp
index 917d628..a754b3d 100644
--- a/akregator/src/createfeedcommand.cpp
+++ b/akregator/src/createfeedcommand.cpp
@@ -26,8 +26,10 @@
 
 #include "addfeeddialog.h"
 #include "feed.h"
+#include "feedlist.h"
 #include "feedpropertiesdialog.h"
 #include "folder.h"
+#include "mainwidget.h"
 #include "subscriptionlistview.h"
 
 #include <KInputDialog>
@@ -50,6 +52,7 @@ public:
 
     void doCreate();
 
+    QPointer<MainWidget> m_parent;
     QPointer<Folder> m_rootFolder;
     QPointer<SubscriptionListView> m_subscriptionListView;
     QString m_url;
@@ -121,18 +124,28 @@ void CreateFeedCommand::Private::doCreate()
     }
     else
     {
-        m_parentFolder = m_parentFolder ? m_parentFolder : m_rootFolder;
-        m_parentFolder->insertChild( feed, m_after );
-        m_subscriptionListView->ensureNodeVisible( feed );
+        if ( !m_parentFolder ) {
+          if ( !m_rootFolder ) {
+            if ( m_parent->allFeedsList() ) {
+              q->setRootFolder( m_parent->allFeedsList()->allFeedsFolder() );
+            }
+          }
+          m_parentFolder = m_rootFolder;
+        }
+
+        if ( m_parentFolder ) {
+          m_parentFolder->insertChild( feed, m_after );
+          m_subscriptionListView->ensureNodeVisible( feed );
+        }
     }
 
     delete dlg;
     q->done();
 }
 
-CreateFeedCommand::CreateFeedCommand( QObject* parent ) : Command( parent ), d( new Private( this ) )
+CreateFeedCommand::CreateFeedCommand( MainWidget* parent ) : Command( parent ), d( new Private( this ) )
 {
-
+    d->m_parent = parent;
 }
 
 CreateFeedCommand::~CreateFeedCommand()
diff --git a/akregator/src/createfeedcommand.h b/akregator/src/createfeedcommand.h
index ccd34f6..b1cb470 100644
--- a/akregator/src/createfeedcommand.h
+++ b/akregator/src/createfeedcommand.h
@@ -30,6 +30,7 @@
 namespace Akregator {
 
 class Folder;
+class MainWidget;
 class SubscriptionListView;
 class TreeNode;
 
@@ -37,7 +38,7 @@ class CreateFeedCommand : public Command
 {
     Q_OBJECT
 public:
-    explicit CreateFeedCommand( QObject* parent = 0 );
+    explicit CreateFeedCommand( MainWidget* parent = 0 );
     ~CreateFeedCommand();
 
     void setSubscriptionListView( SubscriptionListView* view );
@@ -45,11 +46,11 @@ public:
     void setUrl( const QString& url );
     void setPosition( Folder* parent, TreeNode* after );
     void setAutoExecute( bool autoexec );
-    
+
 private:
     void doStart();
     void doAbort();
-    
+
 private:
     class Private;
     Private* const d;
diff --git a/akregator/src/mainwidget.h b/akregator/src/mainwidget.h
index a832cf3..ec18b2c 100644
--- a/akregator/src/mainwidget.h
+++ b/akregator/src/mainwidget.h
@@ -102,6 +102,11 @@ class AKREGATORPART_EXPORT MainWidget : public QWidget
          */
         void addFeedToGroup(const QString& url, const QString& group);
 
+        boost::shared_ptr<FeedList> allFeedsList()
+        {
+            return m_feedList;
+        }
+
         /** session management **/
         void readProperties(const KConfigGroup & config);
         void saveProperties(KConfigGroup & config);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic