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

List:       kde-commits
Subject:    [smb4k] core: Fixed two crashes in the previewer: The first occurred when authentication
From:       Alexander Reinholdt <alexander.reinholdt () kdemail ! net>
Date:       2014-04-06 8:54:05
Message-ID: E1WWiq5-0000nn-Ab () scm ! kde ! org
[Download RAW message or body]

Git commit 2cb8de948e9cdca6827ca7d6f1bfc827af0a0c8e by Alexander Reinholdt.
Committed on 06/04/2014 at 08:43.
Pushed by areinholdt into branch 'master'.

Fixed two crashes in the previewer: The first occurred when authentication
data was requested and the password dialog was just closed and the other
one occurred when a recurring authentication error happened.

M  +9    -2    core/smb4kpreviewer.cpp
M  +68   -64   core/smb4kpreviewer_p.cpp

http://commits.kde.org/smb4k/2cb8de948e9cdca6827ca7d6f1bfc827af0a0c8e

diff --git a/core/smb4kpreviewer.cpp b/core/smb4kpreviewer.cpp
index 33a260c..8b044b0 100644
--- a/core/smb4kpreviewer.cpp
+++ b/core/smb4kpreviewer.cpp
@@ -253,9 +253,15 @@ void Smb4KPreviewer::slotJobFinished( KJob *job )
 
 void Smb4KPreviewer::slotAuthError( Smb4KPreviewJob *job )
 {
-  if ( Smb4KWalletManager::self()->showPasswordDialog( job->share(), \
job->parentWidget() ) ) +  // To avoid a crash here because after the \
password dialog closed +  // the job is gone, immediately get the needed \
data. +  Smb4KShare *share = job->share();
+  QWidget *parent   = job->parentWidget();
+  KUrl location     = job->location();
+  
+  if ( Smb4KWalletManager::self()->showPasswordDialog( share, parent ) )
   {
-    slotAcquirePreview( job->share(), job->location(), job->parentWidget() \
); +    slotAcquirePreview( share, location, parent );
   }
   else
   {
@@ -297,6 +303,7 @@ void Smb4KPreviewer::slotAcquirePreview( Smb4KShare \
*share, const KUrl &url, QWi  {
     job->setObjectName( QString( "PreviewJob_%1" ).arg( share->homeUNC() ) \
);  }
+  
   job->setupPreview( share, url, parent );
 
   connect( job,  SIGNAL(result(KJob*)),
diff --git a/core/smb4kpreviewer_p.cpp b/core/smb4kpreviewer_p.cpp
index 2311dc7..2d16e09 100644
--- a/core/smb4kpreviewer_p.cpp
+++ b/core/smb4kpreviewer_p.cpp
@@ -352,93 +352,97 @@ void Smb4KPreviewJob::slotStartPreview()
 
 void Smb4KPreviewJob::slotReadStandardOutput()
 {
-  QStringList list = QString::fromUtf8( m_proc->readAllStandardOutput(), \
                -1 ).split( '\n', QString::SkipEmptyParts );
-  QList<Item> items;
-
-  foreach ( const QString &line, list )
+  QString stdout = QString::fromUtf8( m_proc->readAllStandardOutput(), -1 \
); +  
+  if ( stdout.contains( "NT_STATUS_ACCESS_DENIED", Qt::CaseSensitive ) || 
+       stdout.contains( "NT_STATUS_LOGON_FAILURE", Qt::CaseSensitive ) )
   {
-    if ( line.contains( "blocks of size" ) || line.contains( "Domain=[" ) \
                )
-    {
-      continue;
-    }
-    else if ( line.contains( "NT_STATUS_ACCESS_DENIED", Qt::CaseSensitive \
                ) ||
-              line.contains( "NT_STATUS_LOGON_FAILURE", Qt::CaseSensitive \
                ) )
-    {
-      // This might happen if a directory cannot be accessed due to \
                missing
-      // read permissions.
-      emit authError( this );
-      break;
-    }
-    else
-    {
-      QString entry = line;
-      
-      QString left = entry.trimmed().section( "     ", 0, -2 ).trimmed();
-      QString right = entry.remove( left );
-
-      QString name = left.section( "  ", 0, -2 ).trimmed().isEmpty() ?
-                     left :
-                     left.section( "  ", 0, -2 ).trimmed();
-
-      QString dir_string = left.right( 3 ).trimmed();
-      bool is_dir = (!dir_string.isEmpty() && dir_string.contains( "D" ));
-
-      QString tmp_size = right.trimmed().section( "  ", 0, 0 ).trimmed();
-      QString size;
+    // This might happen if a directory cannot be accessed due to missing
+    // read permissions.
+    emit authError( this );
+  }
+  else
+  {
+    QStringList list = stdout.split( '\n', QString::SkipEmptyParts );
+    QList<Item> items;
 
-      if ( tmp_size[0].isLetter() )
+    foreach ( const QString &line, list )
+    {
+      if ( line.contains( "blocks of size" ) || line.contains( "Domain=[" \
) )  {
-        size = right.trimmed().section( "  ", 1, 1 ).trimmed();
+        continue;
       }
       else
       {
-        size = tmp_size;
-      }
+        QString entry = line;
+        
+        QString left = entry.trimmed().section( "     ", 0, -2 \
).trimmed(); +        QString right = entry.remove( left );
 
-      QString date = QDateTime::fromString( right.section( QString( " %1 " \
).arg( size ), 1, 1 ).trimmed() ).toString(); +        QString name = \
left.section( "  ", 0, -2 ).trimmed().isEmpty() ? +                       \
left : +                       left.section( "  ", 0, -2 ).trimmed();
 
-      if ( !name.isEmpty() )
-      {
-        Item item;
+        QString dir_string = left.right( 3 ).trimmed();
+        bool is_dir = (!dir_string.isEmpty() && dir_string.contains( "D" \
)); +
+        QString tmp_size = right.trimmed().section( "  ", 0, 0 \
).trimmed(); +        QString size;
 
-        if ( is_dir )
+        if ( tmp_size[0].isLetter() )
         {
-          if ( name.startsWith( '.' ) &&
-              (QString::compare( name, "." ) != 0 && QString::compare( \
                name, ".." ) != 0) )
-          {
-            item.first = HiddenDirectoryItem;
-          }
-          else
-          {
-            item.first = DirectoryItem;
-          }
+          size = right.trimmed().section( "  ", 1, 1 ).trimmed();
         }
         else
         {
-          if ( name.startsWith( '.' ) )
+          size = tmp_size;
+        }
+
+        QString date = QDateTime::fromString( right.section( QString( " %1 \
" ).arg( size ), 1, 1 ).trimmed() ).toString(); +
+        if ( !name.isEmpty() )
+        {
+          Item item;
+
+          if ( is_dir )
           {
-            item.first = HiddenFileItem;
+            if ( name.startsWith( '.' ) &&
+                 (QString::compare( name, "." ) != 0 && QString::compare( \
name, ".." ) != 0) ) +            {
+              item.first = HiddenDirectoryItem;
+            }
+            else
+            {
+              item.first = DirectoryItem;
+            }
           }
           else
           {
-            item.first = FileItem;
+            if ( name.startsWith( '.' ) )
+            {
+              item.first = HiddenFileItem;
+            }
+            else
+            {
+              item.first = FileItem;
+            }
           }
-        }
 
-        item.second["name"] = name;
-        item.second["size"] = size;
-        item.second["date"] = date;
+          item.second["name"] = name;
+          item.second["size"] = size;
+          item.second["date"] = date;
 
-        items << item;
-      }
-      else
-      {
-        continue;
+          items << item;
+        }
+        else
+        {
+          continue;
+        }
       }
     }
-  }
 
-  emit preview( m_url, items );
+    emit preview( m_url, items );
+  }
 }
 
 


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

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