Skip to content

Commit

Permalink
Guard against ObjectDisposedException in Post call
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsenko committed May 23, 2017
1 parent 52c64c2 commit 6ce1729
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
</Reference>
<Reference Include="FastAndroidCamera">
<HintPath>..\..\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath>
<HintPath>..\..\Samples\Forms\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand All @@ -64,10 +63,9 @@
<Compile Include="ZXingSurfaceView.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="PermissionsHandler.cs" />
<Compile Include="FastJavaArrayEx.cs" />
<Compile Include="ZXingTextureView.cs" />
<Compile Include="FastJavaByteArrayYUVLuminanceSource.cs" />
<Compile Include="FastJavaArrayEx.cs" />
<Compile Include="ZXingTextureView.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
Expand Down
8 changes: 7 additions & 1 deletion Source/ZXing.Net.Mobile.Android/ZXingTextureView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,13 @@ void SetSurfaceTransform(SurfaceTexture st, int width, int height)
var transform = new Matrix();
transform.SetScale(1f, aspectRatio * width / height); // lock on to width

Post(() => SetTransform(transform)); // ensure we use the right thread when updating transform
Post(() => {
try
{
SetTransform(transform);
}
catch (ObjectDisposedException) { } // todo: What to do here?! For now we squash :-/
}); // ensure we use the right thread when updating transform

Log.Debug(MobileBarcodeScanner.TAG, $"Aspect ratio: {aspectRatio}, Transform: {transform}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@
<Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Xamarin.Forms.2.3.3.193\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath>
</Reference>
<Reference Include="FastAndroidCamera">
<HintPath>..\..\Samples\Forms\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath>
</Reference>
<Reference Include="FastAndroidCamera">
<HintPath>..\..\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -141,6 +138,4 @@
<Error Condition="!Exists('..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets'))" />
</Target>
<Import Project="..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.3.193\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
</Project>
<Import Project="..\..\packages\Xamarin.Forms.2.3.0.107\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.3.0.107\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
</Project>

0 comments on commit 6ce1729

Please sign in to comment.