travisjeffery / ClangFormat-Xcode

Xcode plug-in to to use clang-format from in Xcode and consistently format your code with Clang
https://twitter.com/travisjeffery
MIT License
2.89k stars 288 forks source link

Crashing...not sure why #49

Open MaximusMcCann opened 9 years ago

MaximusMcCann commented 9 years ago

Was working flawlessly. Feel like it goofed on one save and now has had problems ever since.

  Thread 0x3885     DispatchQueue 1          priority 47         cpu time   0.009s
  10 start + 1 (libdyld.dylib) [0x7fff86dc35fd]
    10 NSApplicationMain + 940 (AppKit) [0x7fff8c5cf783]
      10 -[NSApplication run] + 646 (AppKit) [0x7fff8c5e49f9]
        10 -[IDEApplication sendEvent:] + 456 (IDEKit) [0x104140600]
          10 -[NSApplication sendEvent:] + 3293 (AppKit) [0x7fff8c794acc]
            10 -[NSApplication _handleKeyEquivalent:] + 822 (AppKit) [0x7fff8c8258e1]
              10 -[NSMenu performKeyEquivalent:] + 289 (AppKit) [0x7fff8c82907c]
                10 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 117 (AppKit) [0x7fff8c829f04]
                  10 -[NSMenuItem _corePerformAction] + 394 (AppKit) [0x7fff8c82a1c8]
                    10 -[DVTApplication sendAction:to:from:] + 377 (DVTKit) [0x1035c6b38]
                      10 __37-[DVTApplication sendAction:to:from:]_block_invoke + 352 (DVTKit) [0x1036f8f85]
                        10 -[NSApplication sendAction:to:from:] + 327 (AppKit) [0x7fff8c80f260]
                          10 -[IDEEditorDocument saveDocument:] + 682 (IDEKit) [0x1041fdb4b]
                            10 -[IDEEditorDocument _unlockIfNeededCompletionBlock:] + 622 (IDEKit) [0x1041fa2ca]
                              10 __34-[IDEEditorDocument saveDocument:]_block_invoke + 56 (IDEKit) [0x1043ae488]
                                10 -[NSDocument(TRVSClangFormat) trvs_saveDocumentWithDelegate:didSaveSelector:contextInfo:] + 165 (ClangFormat) [0x109426be5]
                                  10 -[TRVSFormatter formatDocument:] + 527 (ClangFormat) [0x109424d1f]
                                    10 -[TRVSFormatter formatRanges:inDocument:] + 245 (ClangFormat) [0x1094250e5]
                                      10 -[TRVSFormatter fragmentsOfContinuousLineRanges:usingTextStorage:withDocument:] + 389 (ClangFormat) [0x109425b85]
                                        10 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 319 (CoreFoundation) [0x7fff8b186a9f]
                                          10 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 137 (CoreFoundation) [0x7fff8b1872f9]
                                            10 __79-[TRVSFormatter fragmentsOfContinuousLineRanges:usingTextStorage:withDocument:]_block_invoke + 719 (ClangFormat) [0x109425f2f]
                                              10 -[TRVSCodeFragment formatWithStyle:usingClangFormatAtLaunchPath:] + 783 (ClangFormat) [0x109423e6f]
                                                10 -[NSConcreteTask waitUntilExit] + 205 (Foundation) [0x7fff868867f8]
                                                  10 CFRunLoopRunSpecific + 309 (CoreFoundation) [0x7fff8b174e75]
                                                    10 __CFRunLoopRun + 1161 (CoreFoundation) [0x7fff8b175539]
                                                      10 __CFRunLoopServiceMachPort + 181 (CoreFoundation) [0x7fff8b175f15]
                                                        10 mach_msg_trap + 10 (libsystem_kernel.dylib) [0x7fff90bd6a1a]
                                                         *10 ipc_mqueue_receive_continue + 0 (mach_kernel) [0xffffff80002167d0]
MaximusMcCann commented 9 years ago

I find it's breaking on this:

// Sort by pickup times
NSArray *timesArray = [[timesDict allValues] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {             
NSDate *d1 = [DateUtility dateForOrderDateString:(NSString *)obj1[@"date"]];
NSDate *d2 = [DateUtility dateForOrderDateString:(NSString *)obj2[@"date"]];
return [d1 compare:d2];
}];
MaximusMcCann commented 9 years ago

This works, but takes 5+ seconds to save:

// Sort by pickup times
NSArray *timesArray = [[timesDict allValues] sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
        NSString *date1 = obj1[@"date"];
        NSString *date2 = obj2[@"date"];
        NSDate *d1 = [DateUtility dateForOrderDateString:date1];
        NSDate *d2 = [DateUtility dateForOrderDateString:date2];
        return [d1 compare:d2];
}];