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
+128 -103

No files matched your search

+104 -89
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,95 +660,109 @@ 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>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100223"> <customView verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="mnz-j4-2OQ">
<rect key="frame" x="8" y="29" width="76" height="17"/> <rect key="frame" x="24" y="0.0" width="340" height="82"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Options:" id="100224"> <subviews>
<font key="font" metaFont="system"/> <button toolTip="Needed for mp4 larger than 4GB." translatesAutoresizingMaskIntoConstraints="NO" id="100188">
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <rect key="frame" x="98" y="28" width="144" height="18"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <buttonCell key="cell" type="check" title="64 bits chunk offset" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100189">
</textFieldCell> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
</textField> <font key="font" metaFont="system"/>
<textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100221"> </buttonCell>
<rect key="frame" x="8" y="54" width="76" height="17"/> <connections>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="File Format:" id="100222"> <binding destination="100263" name="value" keyPath="values.mp464bitOffset" id="100265"/>
<font key="font" metaFont="system"/> </connections>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> </button>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> <textField verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="YES" preferredMaxLayoutWidth="250" translatesAutoresizingMaskIntoConstraints="NO" id="100223">
</textFieldCell> <rect key="frame" x="18" y="29" width="76" height="17"/>
</textField> <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Options:" id="100224">
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="100215"> <font key="font" metaFont="system"/>
<rect key="frame" x="88" y="48" width="225" height="26"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<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"> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> </textFieldCell>
<font key="font" metaFont="menu"/> </textField>
<menu key="menu" title="OtherViews" autoenablesItems="NO" id="100217"> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="100215">
<items> <rect key="frame" x="98" y="48" width="225" height="26"/>
<menuItem title="Item 1" state="on" id="100218"> <constraints>
<modifierMask key="keyEquivalentModifierMask"/> <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="220" id="CWX-o0-H8Z"/>
<connections> </constraints>
<action selector="setSaveFormat:" target="-2" id="100242"/> <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">
</connections> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
</menuItem> <font key="font" metaFont="menu"/>
<menuItem title="Item 2" tag="1" id="100219"> <menu key="menu" title="OtherViews" autoenablesItems="NO" id="100217">
<modifierMask key="keyEquivalentModifierMask"/> <items>
</menuItem> <menuItem title="Item 1" state="on" id="100218">
<menuItem title="Item 3" tag="2" id="100220"> <modifierMask key="keyEquivalentModifierMask"/>
<modifierMask key="keyEquivalentModifierMask"/> <connections>
</menuItem> <action selector="setSaveFormat:" target="-2" id="100242"/>
</items> </connections>
</menu> </menuItem>
</popUpButtonCell> <menuItem title="Item 2" tag="1" id="100219">
<connections> <modifierMask key="keyEquivalentModifierMask"/>
<action selector="setSaveFormat:" target="-2" id="100243"/> </menuItem>
<binding destination="100263" name="selectedIndex" keyPath="values.defaultSaveFormat" id="100294"> <menuItem title="Item 3" tag="2" id="100220">
<dictionary key="options"> <modifierMask key="keyEquivalentModifierMask"/>
<bool key="NSValidatesImmediately" value="YES"/> </menuItem>
</dictionary> </items>
</binding> </menu>
</connections> </popUpButtonCell>
</popUpButton> <connections>
<button translatesAutoresizingMaskIntoConstraints="NO" id="100190"> <action selector="setSaveFormat:" target="-2" id="100243"/>
<rect key="frame" x="88" y="8" width="102" height="18"/> <binding destination="100263" name="selectedIndex" keyPath="values.defaultSaveFormat" id="100294">
<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. <dictionary key="options">
<bool key="NSValidatesImmediately" value="YES"/>
</dictionary>
</binding>
</connections>
</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">
<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.
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">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/> <font key="font" metaFont="system"/>
</buttonCell> </buttonCell>
<connections> <connections>
<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"> </subviews>
<rect key="frame" x="88" y="28" width="144" height="18"/> <constraints>
<buttonCell key="cell" type="check" title="64 bits chunk offset" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="100189"> <constraint firstItem="100190" firstAttribute="top" secondItem="100188" secondAttribute="bottom" constant="6" id="46F-aM-wkb"/>
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <constraint firstItem="100190" firstAttribute="leading" secondItem="100188" secondAttribute="leading" id="GqE-pf-8l4"/>
<font key="font" metaFont="system"/> <constraint firstItem="100223" firstAttribute="trailing" secondItem="100221" secondAttribute="trailing" id="M7Q-Pf-AoO"/>
</buttonCell> <constraint firstItem="100223" firstAttribute="top" secondItem="100221" secondAttribute="bottom" constant="8" id="NIO-40-Ff9"/>
<connections> <constraint firstAttribute="height" constant="82" id="QgN-pP-fGp"/>
<binding destination="100263" name="value" keyPath="values.mp464bitOffset" id="100265"/> <constraint firstAttribute="bottom" secondItem="100190" secondAttribute="bottom" constant="10" id="QnU-Cc-d7I"/>
</connections> <constraint firstItem="100215" firstAttribute="leading" secondItem="100221" secondAttribute="trailing" constant="8" symbolic="YES" id="TfO-H6-1Fr"/>
</button> <constraint firstItem="100221" firstAttribute="top" secondItem="mnz-j4-2OQ" secondAttribute="top" constant="11" id="W1f-ha-gXm"/>
<constraint firstItem="100223" firstAttribute="width" secondItem="100221" secondAttribute="width" id="Ykt-xh-F12"/>
<constraint firstItem="100188" firstAttribute="baseline" secondItem="100223" secondAttribute="baseline" id="ZDc-Ug-oGw"/>
<constraint firstItem="100215" firstAttribute="baseline" secondItem="100221" secondAttribute="baseline" id="kJ4-iW-o2W"/>
<constraint firstItem="100221" firstAttribute="leading" secondItem="mnz-j4-2OQ" secondAttribute="leading" constant="20" id="rRR-Vf-emg"/>
<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>
</customView>
</subviews> </subviews>
<constraints> <constraints>
<constraint firstItem="100223" firstAttribute="top" secondItem="100221" secondAttribute="bottom" constant="8" id="1z2-hb-G9o"/> <constraint firstItem="mnz-j4-2OQ" firstAttribute="centerX" secondItem="100187" secondAttribute="centerX" id="Iri-xR-u1f"/>
<constraint firstAttribute="bottom" secondItem="100190" secondAttribute="bottom" constant="10" id="C2J-In-ZOs"/> <constraint firstAttribute="bottom" secondItem="mnz-j4-2OQ" secondAttribute="bottom" id="cst-WF-TrG"/>
<constraint firstItem="100215" firstAttribute="leading" secondItem="100221" secondAttribute="trailing" constant="8" symbolic="YES" id="EY7-ee-NKd"/> <constraint firstItem="mnz-j4-2OQ" firstAttribute="top" secondItem="100187" secondAttribute="top" id="hgc-7Q-CTY"/>
<constraint firstItem="100221" firstAttribute="leading" secondItem="100187" secondAttribute="leading" constant="10" id="Gcm-uM-dEu"/>
<constraint firstItem="100188" firstAttribute="baseline" secondItem="100223" secondAttribute="baseline" id="W3i-6N-fzc"/>
<constraint firstItem="100221" firstAttribute="top" secondItem="100187" secondAttribute="top" constant="11" id="W8Z-D3-oZH"/>
<constraint firstItem="100190" firstAttribute="top" secondItem="100188" secondAttribute="bottom" constant="6" id="XM7-Xc-98Y"/>
<constraint firstItem="100215" firstAttribute="baseline" secondItem="100221" secondAttribute="baseline" id="YtU-ce-ots"/>
<constraint firstItem="100223" firstAttribute="trailing" secondItem="100221" secondAttribute="trailing" id="ble-rf-5sO"/>
<constraint firstItem="100188" firstAttribute="leading" secondItem="100223" secondAttribute="trailing" constant="8" symbolic="YES" id="eW1-2L-pww"/>
<constraint firstItem="100190" firstAttribute="leading" secondItem="100188" secondAttribute="leading" id="hSd-gT-lZY"/>
<constraint firstItem="100223" firstAttribute="width" secondItem="100221" secondAttribute="width" id="i3a-54-8hq"/>
<constraint firstAttribute="trailing" secondItem="100215" secondAttribute="trailing" constant="10" id="lgy-LM-55n"/>
</constraints> </constraints>
<point key="canvasLocation" x="-195" y="189"/> <point key="canvasLocation" x="-338" y="186"/>
</customView> </customView>
<userDefaultsController representsSharedInstance="YES" id="100263"/> <userDefaultsController representsSharedInstance="YES" id="100263"/>
</objects> </objects>
+7 -5
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];
if (newStatus != SBQueueItemStatusReady && newStatus != SBQueueItemStatusEditing) { dispatch_async(dispatch_get_main_queue(), ^{
[self.editButton setEnabled:NO]; if (newStatus != SBQueueItemStatusReady && newStatus != SBQueueItemStatusEditing) {
} else { [self.editButton setEnabled:NO];
[self.editButton setEnabled:YES]; } else {
} [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);
+9 -7
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;
} }
// Enable sleep assertion
[self disableSleep];
dispatch_async(self.workQueue, ^{ dispatch_async(self.workQueue, ^{
// Enable sleep assertion
[self disableSleep];
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];