2012-10-12 47 views
38

我在Xcode 4.5.1上。我認爲這是我看到的相對較新的行爲。如何知道何時可以忽略所有異常斷點上的__cxa_throw?

我更願意在啓用「所有異常」斷點的情況下開發和測試我的項目。

我一直在遇到一個場景,我將一個縮略圖圖像加載到tableview中的單元格,在那裏我得到一個__cxa_throw異常。當我點擊「繼續執行程序」按鈕時,Xcode繼續它的快樂方式。我得到縮略圖。應用程序似乎工作正常。我正在尋找一些關於如何確定這是否可以安全忽略的提示。就像也許一些理解棧跟蹤的指針?或者是其他東西?

這裏的代碼片段:

NSString *imageStr = item.thumbURL; 
    imageStr = [imageStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
    NSURL *imageURL; 

    if (![imageStr isEqualToString:@""]) { 
     imageURL = [NSURL URLWithString:imageStr]; 
     NSLog(@"imageURL: %@",imageURL); 
     if (imageURL == nil) { 
      NSLog(@"imageUrl was nil for string: %@",imageStr); 
     } else { 
      UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
      //spinner.frame = CGRectMake(cell.imageView.frame.size.width/2,cell.imageView.frame.origin.y + cell.imageView.frame.size.height/2,cell.imageView.frame.size.width,cell.imageView.frame.size.height); 
      spinner.frame = CGRectMake(10,20,40,40); 
      [spinner startAnimating]; 
      [cell addSubview:spinner]; 

      dispatch_queue_t downloadQueue = dispatch_queue_create("thumbnail downloader", NULL); 
      dispatch_async(downloadQueue, ^{ 
       NSLog(@"Network request for tour_thumb image: %@",imageStr); 
       UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:imageURL]]; 
       dispatch_async(dispatch_get_main_queue(), ^{ 
        [spinner removeFromSuperview]; 
        UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(8, 8, cell.contentView.frame.size.width/2 - 16, cell.contentView.frame.size.height - 16)]; 
        imgView.image = img; 
        [cell.contentView addSubview:imgView]; 
       }); 
      }); 
      dispatch_release(downloadQueue); 
     } 
    } 

這是我看到的堆棧跟蹤:

#0 0x34a9c524 in __cxa_throw() 
#1 0x387014ce in AddChildNode(XMP_Node*, XML_Node const&, char const*, bool)() 
#2 0x38700d22 in RDF_LiteralPropertyElement(XMP_Node*, XML_Node const&, bool)() 
#3 0x3870094e in RDF_PropertyElementList(XMP_Node*, XML_Node const&, bool)() 
#4 0x38700608 in ProcessRDF(XMP_Node*, XML_Node const&, unsigned int)() 
#5 0x3871480a in XMPMeta::ParseFromBuffer(char const*, unsigned int, unsigned int)() 
#6 0x387095c0 in WXMPMeta_ParseFromBuffer_1() 
#7 0x38725578 in TXMPMeta<std::string>::ParseFromBuffer(char const*, unsigned int, unsigned int)() 
#8 0x387254de in TXMPMeta<std::string>::TXMPMeta(char const*, unsigned int)() 
#9 0x38722b70 in CreateMetadataFromXMPDataInternal(char const*, unsigned long, unsigned int)() 
#10 0x38739a50 in readXMPProperties() 
#11 0x386a01fc in readXMPData() 
#12 0x3868cec8 in initImageJPEG() 
#13 0x3868c2ee in _CGImagePluginInitJPEG() 
#14 0x3867e274 in makeImagePlus() 
#15 0x3867ddde in CGImageSourceCreateImageAtIndex() 
#16 0x38e117b6 in _UIImageRefFromData() 
#17 0x38e116c6 in -[UIImage initWithData:]() 
#18 0x0004cb0a in __57-[ViewController tableView:cellForRowAtIndexPath:]_block_invoke_0 at ViewController.m:335 
#19 0x313fc792 in _dispatch_call_block_and_release() 
#20 0x313ffb3a in _dispatch_queue_drain() 
#21 0x313fd67c in _dispatch_queue_invoke() 
#22 0x31400612 in _dispatch_root_queue_drain() 
#23 0x314007d8 in _dispatch_worker_thread2() 
#24 0x394767f0 in _pthread_wqthread() 
#25 0x39476684 in start_wqthread() 
+1

這個問題和下面的答案(即只捕獲標準的Objective-C異常)同樣適用於Xcode 7.2.1,也可能適用於以後的版本。 – bluebinary

回答

57

這顯然是實現中深和C++異常可能是部分正常流量,如果他們決定使用異常來在內部發出錯誤信號。

如果你自己沒有編寫任何C++,那麼它可以安全地忽略。

只是陷阱標準的Objective-C異常:

objc_exception_throw 
+20

謝謝,trojanfoe。我編輯了斷點,將「Exception:All」更改爲「Exception:Objective-C」。這很有道理。 –

+5

以防萬一有人達到此目的,不知道如何去做:) http://stackoverflow.com/a/14767076/2298217 – iamdavidlam

29

去這裏:

enter image description here

而做到這一點:

enter image description here

要關閉此:

enter image description here

到這一點:

enter image description here

你仍然得到了很多增加斷點的利益,但不會有你的應用程序崩潰的東西,你可能不無論如何負責。現在,如果您正在使用C++,那麼您會更好地擔心它。

+2

有幫助,謝謝。 –

相關問題