Fix some threading issues.

This commit is contained in:
Damiano Galassi committed 2017-06-20 16:17:33 +02:00
1 parent cd67331db2
commit 11028208b8
4 files changed
+75 -50

No files matched your search

+57 -42
View File
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="12118" systemVersion="16E192b" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="13122.17" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies> <dependencies>
<deployment identifier="macosx"/> <deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="12118"/> <development version="8000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13122.17"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies> </dependencies>
<objects> <objects>
@@ -39,7 +40,7 @@
<value key="minSize" type="size" width="350" height="200"/> <value key="minSize" type="size" width="350" height="200"/>
<view key="contentView" id="6"> <view key="contentView" id="6">
<rect key="frame" x="0.0" y="0.0" width="690" height="510"/> <rect key="frame" x="0.0" y="0.0" width="690" height="510"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<splitView translatesAutoresizingMaskIntoConstraints="NO" id="100127"> <splitView translatesAutoresizingMaskIntoConstraints="NO" id="100127">
<rect key="frame" x="-1" y="0.0" width="692" height="511"/> <rect key="frame" x="-1" y="0.0" width="692" height="511"/>
@@ -548,7 +549,7 @@
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="100176"> <view key="contentView" id="100176">
<rect key="frame" x="0.0" y="0.0" width="297" height="121"/> <rect key="frame" x="0.0" y="0.0" width="297" height="121"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="100177"> <textField verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="100177">
<rect key="frame" x="17" y="84" width="88" height="17"/> <rect key="frame" x="17" y="84" width="88" height="17"/>
@@ -579,7 +580,7 @@ Gw
</button> </button>
</subviews> </subviews>
</view> </view>
<point key="canvasLocation" x="437" y="408"/> <point key="canvasLocation" x="321" y="278"/>
</window> </window>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="100271" userLabel="Offset"> <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" visibleAtLaunch="NO" animationBehavior="default" id="100271" userLabel="Offset">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
@@ -588,7 +589,7 @@ Gw
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<view key="contentView" id="100272"> <view key="contentView" id="100272">
<rect key="frame" x="0.0" y="0.0" width="346" height="102"/> <rect key="frame" x="0.0" y="0.0" width="346" height="102"/>
<autoresizingMask key="autoresizingMask"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="100277"> <textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="100277">
<rect key="frame" x="307" y="62" width="22" height="17"/> <rect key="frame" x="307" y="62" width="22" height="17"/>
@@ -659,27 +660,35 @@ Gw
</view> </view>
</window> </window>
<customView id="100187"> <customView id="100187">
<rect key="frame" x="0.0" y="0.0" width="320" height="82"/> <rect key="frame" x="0.0" y="0.0" width="388" height="82"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews> <subviews>
<customView verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="mnz-j4-2OQ">
<rect key="frame" x="24" y="0.0" width="340" height="82"/>
<subviews>
<button toolTip="Needed for mp4 larger than 4GB." translatesAutoresizingMaskIntoConstraints="NO" id="100188">
<rect key="frame" x="98" y="28" width="144" height="18"/>
<buttonCell key="cell" type="check" title="64 bits chunk offset" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100189">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="100263" name="value" keyPath="values.mp464bitOffset" id="100265"/>
</connections>
</button>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100223"> <textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100223">
<rect key="frame" x="8" y="29" width="76" height="17"/> <rect key="frame" x="18" y="29" width="76" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Options:" id="100224"> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Options:" id="100224">
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100221">
<rect key="frame" x="8" y="54" width="76" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="File Format:" id="100222">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="100215"> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="100215">
<rect key="frame" x="88" y="48" width="225" height="26"/> <rect key="frame" x="98" y="48" width="225" height="26"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="220" id="CWX-o0-H8Z"/>
</constraints>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="100218" id="100216"> <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" autoenablesItems="NO" selectedItem="100218" id="100216">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="menu"/> <font key="font" metaFont="menu"/>
@@ -709,8 +718,16 @@ Gw
</binding> </binding>
</connections> </connections>
</popUpButton> </popUpButton>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100221">
<rect key="frame" x="18" y="54" width="76" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="File Format:" id="100222">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="100190"> <button translatesAutoresizingMaskIntoConstraints="NO" id="100190">
<rect key="frame" x="88" y="8" width="102" height="18"/> <rect key="frame" x="98" y="8" width="102" height="18"/>
<string key="toolTip">Note: don't use this option if you are not sure of what it is doing, it's not needed in almost every case. <string key="toolTip">Note: don't use this option if you are not sure of what it is doing, it's not needed in almost every case.
Enable 64bit timescale and duration support. Normally, it's only needed if a track will be longer than 10 hours.</string> Enable 64bit timescale and duration support. Normally, it's only needed if a track will be longer than 10 hours.</string>
<buttonCell key="cell" type="check" title="64 bits times" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100191"> <buttonCell key="cell" type="check" title="64 bits times" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100191">
@@ -721,33 +738,31 @@ Enable 64bit timescale and duration support. Normally, it's only needed if a tra
<binding destination="100263" name="value" keyPath="values.mp464bitTimes" id="100266"/> <binding destination="100263" name="value" keyPath="values.mp464bitTimes" id="100266"/>
</connections> </connections>
</button> </button>
<button toolTip="Needed for mp4 larger than 4GB." translatesAutoresizingMaskIntoConstraints="NO" id="100188">
<rect key="frame" x="88" y="28" width="144" height="18"/>
<buttonCell key="cell" type="check" title="64 bits chunk offset" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100189">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="100263" name="value" keyPath="values.mp464bitOffset" id="100265"/>
</connections>
</button>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="100223" firstAttribute="top" secondItem="100221" secondAttribute="bottom" constant="8" id="1z2-hb-G9o"/> <constraint firstItem="100190" firstAttribute="top" secondItem="100188" secondAttribute="bottom" constant="6" id="46F-aM-wkb"/>
<constraint firstAttribute="bottom" secondItem="100190" secondAttribute="bottom" constant="10" id="C2J-In-ZOs"/> <constraint firstItem="100190" firstAttribute="leading" secondItem="100188" secondAttribute="leading" id="GqE-pf-8l4"/>
<constraint firstItem="100215" firstAttribute="leading" secondItem="100221" secondAttribute="trailing" constant="8" symbolic="YES" id="EY7-ee-NKd"/> <constraint firstItem="100223" firstAttribute="trailing" secondItem="100221" secondAttribute="trailing" id="M7Q-Pf-AoO"/>
<constraint firstItem="100221" firstAttribute="leading" secondItem="100187" secondAttribute="leading" constant="10" id="Gcm-uM-dEu"/> <constraint firstItem="100223" firstAttribute="top" secondItem="100221" secondAttribute="bottom" constant="8" id="NIO-40-Ff9"/>
<constraint firstItem="100188" firstAttribute="baseline" secondItem="100223" secondAttribute="baseline" id="W3i-6N-fzc"/> <constraint firstAttribute="height" constant="82" id="QgN-pP-fGp"/>
<constraint firstItem="100221" firstAttribute="top" secondItem="100187" secondAttribute="top" constant="11" id="W8Z-D3-oZH"/> <constraint firstAttribute="bottom" secondItem="100190" secondAttribute="bottom" constant="10" id="QnU-Cc-d7I"/>
<constraint firstItem="100190" firstAttribute="top" secondItem="100188" secondAttribute="bottom" constant="6" id="XM7-Xc-98Y"/> <constraint firstItem="100215" firstAttribute="leading" secondItem="100221" secondAttribute="trailing" constant="8" symbolic="YES" id="TfO-H6-1Fr"/>
<constraint firstItem="100215" firstAttribute="baseline" secondItem="100221" secondAttribute="baseline" id="YtU-ce-ots"/> <constraint firstItem="100221" firstAttribute="top" secondItem="mnz-j4-2OQ" secondAttribute="top" constant="11" id="W1f-ha-gXm"/>
<constraint firstItem="100223" firstAttribute="trailing" secondItem="100221" secondAttribute="trailing" id="ble-rf-5sO"/> <constraint firstItem="100223" firstAttribute="width" secondItem="100221" secondAttribute="width" id="Ykt-xh-F12"/>
<constraint firstItem="100188" firstAttribute="leading" secondItem="100223" secondAttribute="trailing" constant="8" symbolic="YES" id="eW1-2L-pww"/> <constraint firstItem="100188" firstAttribute="baseline" secondItem="100223" secondAttribute="baseline" id="ZDc-Ug-oGw"/>
<constraint firstItem="100190" firstAttribute="leading" secondItem="100188" secondAttribute="leading" id="hSd-gT-lZY"/> <constraint firstItem="100215" firstAttribute="baseline" secondItem="100221" secondAttribute="baseline" id="kJ4-iW-o2W"/>
<constraint firstItem="100223" firstAttribute="width" secondItem="100221" secondAttribute="width" id="i3a-54-8hq"/> <constraint firstItem="100221" firstAttribute="leading" secondItem="mnz-j4-2OQ" secondAttribute="leading" constant="20" id="rRR-Vf-emg"/>
<constraint firstAttribute="trailing" secondItem="100215" secondAttribute="trailing" constant="10" id="lgy-LM-55n"/> <constraint firstItem="100188" firstAttribute="leading" secondItem="100223" secondAttribute="trailing" constant="8" symbolic="YES" id="rsC-rt-qfA"/>
<constraint firstAttribute="trailing" secondItem="100215" secondAttribute="trailing" constant="20" id="v0b-Gj-Oxi"/>
</constraints> </constraints>
<point key="canvasLocation" x="-195" y="189"/> </customView>
</subviews>
<constraints>
<constraint firstItem="mnz-j4-2OQ" firstAttribute="centerX" secondItem="100187" secondAttribute="centerX" id="Iri-xR-u1f"/>
<constraint firstAttribute="bottom" secondItem="mnz-j4-2OQ" secondAttribute="bottom" id="cst-WF-TrG"/>
<constraint firstItem="mnz-j4-2OQ" firstAttribute="top" secondItem="100187" secondAttribute="top" id="hgc-7Q-CTY"/>
</constraints>
<point key="canvasLocation" x="-338" y="186"/>
</customView> </customView>
<userDefaultsController representsSharedInstance="YES" id="100263"/> <userDefaultsController representsSharedInstance="YES" id="100263"/>
</objects> </objects>
+2
View File
@@ -70,11 +70,13 @@ static void *SBItemViewContex = &SBItemViewContex;
// is different from ready // is different from ready
if ([keyPath isEqualToString:@"item.status"]) { if ([keyPath isEqualToString:@"item.status"]) {
SBQueueItemStatus newStatus = [[change valueForKey:NSKeyValueChangeNewKey] integerValue]; SBQueueItemStatus newStatus = [[change valueForKey:NSKeyValueChangeNewKey] integerValue];
dispatch_async(dispatch_get_main_queue(), ^{
if (newStatus != SBQueueItemStatusReady && newStatus != SBQueueItemStatusEditing) { if (newStatus != SBQueueItemStatusReady && newStatus != SBQueueItemStatusEditing) {
[self.editButton setEnabled:NO]; [self.editButton setEnabled:NO];
} else { } else {
[self.editButton setEnabled:YES]; [self.editButton setEnabled:YES];
} }
});
} else if ([keyPath isEqualToString:@"item.actions"]) { } else if ([keyPath isEqualToString:@"item.actions"]) {
NSInteger count = [change[NSKeyValueChangeNewKey] count] - [change[NSKeyValueChangeOldKey] count]; NSInteger count = [change[NSKeyValueChangeNewKey] count] - [change[NSKeyValueChangeOldKey] count];
CGFloat height = TABLE_ROW_HEIGHT * (count >= 0 ? count : 1); CGFloat height = TABLE_ROW_HEIGHT * (count >= 0 ? count : 1);
+8 -6
View File
@@ -222,22 +222,25 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
* Starts the queue. * Starts the queue.
*/ */
- (void)start { - (void)start {
if (self.status == SBQueueStatusWorking) { if (self.status == SBQueueStatusWorking || self.cancelled) {
return; return;
} else { } else {
self.status = SBQueueStatusWorking; self.status = SBQueueStatusWorking;
} }
dispatch_async(self.workQueue, ^{
// Enable sleep assertion // Enable sleep assertion
[self disableSleep]; [self disableSleep];
dispatch_async(self.workQueue, ^{
NSUInteger completedCount = 0; NSUInteger completedCount = 0;
NSUInteger failedCount = 0; NSUInteger failedCount = 0;
for (;;) { for (;;) {
@autoreleasepool { @autoreleasepool {
// Save to disk
[self saveQueueToDisk];
NSError *outError = nil; NSError *outError = nil;
BOOL noErr = NO; BOOL noErr = NO;
@@ -280,6 +283,8 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
self.currentItem.delegate = nil; self.currentItem.delegate = nil;
self.currentItem = nil; self.currentItem = nil;
[self handleSBStatusWorking:100 index:self.currentIndex];
} }
if (self.status == SBQueueStatusCancelled) { if (self.status == SBQueueStatusCancelled) {
@@ -287,9 +292,6 @@ NSString *SBQueueCancelledNotification = @"SBQueueCancelledNotification";
} }
} }
// Save to disk
[self saveQueueToDisk];
// Disable sleep assertion // Disable sleep assertion
[self enableSleep]; [self enableSleep];
[self handleSBStatusCompleted:completedCount failed:failedCount]; [self handleSBStatusCompleted:completedCount failed:failedCount];
+8 -2
View File
@@ -97,8 +97,9 @@ static void *SBQueueContex = &SBQueueContex;
[self.progressBar setIndeterminate:NO]; [self.progressBar setIndeterminate:NO];
self.progressBar.doubleValue = [[info valueForKey:@"Progress"] doubleValue]; self.progressBar.doubleValue = [[info valueForKey:@"Progress"] doubleValue];
if ([info[@"ItemIndex"] integerValue] != -1) { NSInteger index = [info[@"ItemIndex"] integerValue];
[self updateUI]; if (index != -1) {
[self updateUIIndexes:[NSIndexSet indexSetWithIndex:index]];
} }
}]; }];
@@ -484,6 +485,11 @@ static void *SBQueueContex = &SBQueueContex;
} }
} }
- (void)updateUIIndexes:(NSIndexSet *)indexes {
[self.table reloadDataForRowIndexes:indexes columnIndexes:[NSIndexSet indexSetWithIndex:0]];
[self updateState];
}
- (void)updateUI { - (void)updateUI {
[self.table reloadData]; [self.table reloadData];
[self updateState]; [self updateState];