]> granicus.if.org Git - transmission/commitdiff
Prevent crash during group rules removal in some cases (OS X)
authorMike Gelfand <mikedld@mikedld.com>
Wed, 2 Mar 2016 07:55:37 +0000 (07:55 +0000)
committerMike Gelfand <mikedld@mikedld.com>
Wed, 2 Mar 2016 07:55:37 +0000 (07:55 +0000)
The crash seems to be caused by animation performed by the rules list and
the window in parallel. This commit disables window resize animation until
a better solution is devised.

Rules list height is now also limited and scrollbar is shown if needed.

12 files changed:
macosx/GroupsPrefsController.h
macosx/GroupsPrefsController.m
macosx/da.lproj/GroupRules.xib
macosx/de.lproj/GroupRules.xib
macosx/en.lproj/GroupRules.xib
macosx/es.lproj/GroupRules.xib
macosx/fr.lproj/GroupRules.xib
macosx/it.lproj/GroupRules.xib
macosx/nl.lproj/GroupRules.xib
macosx/pt_PT.lproj/GroupRules.xib
macosx/ru.lproj/GroupRules.xib
macosx/tr.lproj/GroupRules.xib

index 7838abf766e174b9a35dcc22ad283000d13b3f6c..dc4277a29dbc557bb176ad9888d4c7ce28d9cc88 100644 (file)
@@ -39,6 +39,8 @@
     
     IBOutlet NSWindow * fGroupRulesSheetWindow;
     IBOutlet NSPredicateEditor * fRuleEditor;
+
+    IBOutlet NSLayoutConstraint * fRuleEditorHeightConstraint;
 }
 
 - (void) addRemoveGroup: (id) sender;
index a5bc2916a14f7ca87abb66afc8a59da34cd274d1..6103ec1715aca5dfd91416fdfd5dfe4fb7c5857e 100644 (file)
 
 - (void) ruleEditorRowsDidChange: (NSNotification *) notification
 {
-    const CGFloat heightDifference = [fRuleEditor numberOfRows] * [fRuleEditor rowHeight] - [fRuleEditor frame].size.height;
-    NSRect windowFrame = [fRuleEditor window].frame;
-    windowFrame.size.height += heightDifference;
-    windowFrame.origin.y -= heightDifference;
+    NSScrollView * ruleEditorScrollView = [fRuleEditor enclosingScrollView];
     
-    [fRuleEditor.window setFrame: windowFrame display: YES animate: YES];
+    const CGFloat rowHeight = [fRuleEditor rowHeight];
+    const CGFloat bordersHeight = [ruleEditorScrollView frame].size.height - [ruleEditorScrollView contentSize].height;
+
+    const CGFloat requiredRowCount = [fRuleEditor numberOfRows];
+    const CGFloat maxVisibleRowCount = (long)((NSHeight([[[fRuleEditor window] screen] visibleFrame]) * 2 / 3) / rowHeight);
+    
+    [fRuleEditorHeightConstraint setConstant: MIN(requiredRowCount, maxVisibleRowCount) * rowHeight + bordersHeight];
+    [ruleEditorScrollView setHasVerticalScroller: requiredRowCount > maxVisibleRowCount];
 }
 
 @end
index 29f7a84d30bc900d0768f78afd0cfff9d29423d7..ab50c81b95033dab6f44816eb27026429531a6b5 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index 11d703f7153ec782579ae777cc77b0e8c43124ca..1ddbeef94d0da691d81c60b69fc6bf2ff712944c 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index db461b0566aa49b13da0eb6516d3a67ffa5ed5f2..e5068aecd6f82baeb61e3ff2f73d1637dbe737af 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index e0508caa3ebfaf33a04cde86d848af2c911c576e..3e8497eeee9546d3285730c3fa6d29205e9f98b2 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index bfc13a68331b8965d495f129c58d99d79d235477..008c45cc74cce1d60a77c3c156e913e9ad7a1e86 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index f7bac96c4e565d8a2db36ef9747656631caefa62..4fad29e5e24575a9d20073531f8a407dfd25c388 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index 7360027fd9f559f6c913e5151aff74a8dc751635..5989b4378c4d8c560b0ebb6ba060c8dd7f0bdbd7 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index fbb31e4fdaae5b501a1f883ac7b7609bfffa3306..6525539cc3d82641f3999480a8fc93f8d137a63d 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index 7b01879ebf422c63c2dc196660e1deb05cd8a48d..c2755d3414120cc0f62100461dc53125aa8ec6fd 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>
index 4ae8b56bfec88b3be26445da57d16464b862c9bf..b39aedb887bb69e6727889ba6100486790059a8a 100644 (file)
@@ -9,6 +9,7 @@
             <connections>
                 <outlet property="fGroupRulesSheetWindow" destination="1" id="17"/>
                 <outlet property="fRuleEditor" destination="34" id="56"/>
+                <outlet property="fRuleEditorHeightConstraint" destination="v6L-SJ-HFk" id="nX1-ss-fWF"/>
             </connections>
         </customObject>
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
@@ -187,7 +188,7 @@ Gw
                         </clipView>
                         <constraints>
                             <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="430" id="T2h-Cn-ygX"/>
-                            <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="50" id="v6L-SJ-HFk"/>
+                            <constraint firstAttribute="height" constant="167" id="v6L-SJ-HFk"/>
                         </constraints>
                         <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="33">
                             <rect key="frame" x="-100" y="-100" width="360" height="15"/>