Browse Source

[批量] - 批量处理列表页,app center收集crash

liujiajie 10 months ago
parent
commit
ffa6115d15

+ 10 - 10
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift

@@ -483,21 +483,21 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
         return self.files.count;
     }
     func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
-        let identifier = tableColumn!.identifier
+        let identifier = tableColumn?.identifier
         let file = self.files[row]
       
-        if identifier.rawValue == "index" {
+        if identifier?.rawValue == "index" {
             let cellView = KMBatchTableCellView(type: .Size)
             _ = row + 1
             cellView.textField?.stringValue = String(format: "%d", row + 1);
             return cellView;
-        } else if identifier.rawValue == "pageRange"{
+        } else if identifier?.rawValue == "pageRange"{
             if (file.currentOperateType == .CreatePDF) {
                 let cellView = KMBatchTableCellView(type: .Size)
                 
                 if (file.fileType == .Image) {
                     let image = NSImage(contentsOfFile: file.filePath)
-                    cellView.textField?.stringValue = String(Int(image!.size.width)) + "x" + String(Int(image!.size.height))
+                    cellView.textField?.stringValue = String(Int(image?.size.width ?? 0)) + "x" + String(Int(image?.size.height ?? 0))
                 }
              
                 return cellView;
@@ -506,7 +506,7 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
                 cellView.updateInterface(file)
                 return cellView;
             }
-        } else if identifier.rawValue == "status"{
+        } else if identifier?.rawValue == "status"{
             let cellView = KMBatchTableCellView(type: .Status)
             if (file.currentOperateType == .CreatePDF) {
                 cellView.updateInterface(file: file, progress: file.progress ?? 0)
@@ -518,11 +518,11 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
                 self?.tableView.reloadData()
             }
             return cellView;
-        } else if identifier.rawValue == "size"{
+        } else if identifier?.rawValue == "size"{
             let cellView = KMBatchTableCellView(type: .Size)
             cellView.updateInterface(file)
             return cellView;
-        } else if identifier.rawValue == "fileName"{
+        } else if identifier?.rawValue == "fileName"{
             let cellView = KMBatchTableCellView(type: .FileName)
             cellView.updateInterface(file)
             let rowView: KMBatchTableRowView = tableView.rowView(atRow: row, makeIfNecessary: true) as! KMBatchTableRowView
@@ -530,16 +530,16 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
                 rowView.backgroundColor = KMAppearance.Status.errBGColor();
             }
             return cellView;
-        } else if identifier.rawValue == "dpi"{
+        } else if identifier?.rawValue == "dpi"{
             let cellView = KMBatchTableCellView(type: .DPI)
             cellView.updateInterface(file)
             return cellView;
-        } else if identifier.rawValue == "dimensions"{
+        } else if identifier?.rawValue == "dimensions"{
             let cellView = KMBatchTableCellView(type: .Size)
             
             if (file.fileType == .Image) {
                 let image = NSImage(contentsOfFile: file.filePath)
-                cellView.textField?.stringValue = String(Int(image!.size.width)) + "x" + String(Int(image!.size.height))
+                cellView.textField?.stringValue = String(Int(image?.size.width ?? 0)) + "x" + String(Int(image?.size.height ?? 0))
             }
          
             return cellView;