]> O.S.I.I.S - jp/crow.git/commitdiff
remove thread.abord (not supported by netcore) and add Mutexes release before asking...
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 27 Jan 2020 12:03:11 +0000 (13:03 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Mon, 27 Jan 2020 12:03:11 +0000 (13:03 +0100)
Crow/Crow.csproj
Crow/src/CrowThread.cs
Crow/src/Interface.cs
Crow/src/Widgets/TemplatedGroup.cs
clean.sh [new file with mode: 0755]

index b162e61649009f1a1e470bda9febff916b7dd3e1..85b4ae969c92c736aeb688fc114033bc13034ce3 100644 (file)
@@ -18,7 +18,7 @@
                <PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
                <PackageProjectUrl>https://github.com/jpbruyere/Crow/wiki</PackageProjectUrl>
                <PackageLicense>https://opensource.org/licenses/MIT</PackageLicense>
-               <PackageIconUrl>https://jpbruyere.github.io/Crow/images/crow.png</PackageIconUrl>
+               <PackageIcon>crow.png</PackageIcon>
                <PackageCopyright>Copyright 2013-2019</PackageCopyright>
                <PackageReleaseNotes>                   
                </PackageReleaseNotes>
@@ -26,7 +26,7 @@
                <GeneratePackageOnBuild>True</GeneratePackageOnBuild>           
                
                <GenerateDocumentationFile>true</GenerateDocumentationFile>    
-               <NoWarn>$(NoWarn);1591</NoWarn>
+               <NoWarn>$(NoWarn);1591;1587;1570;1572;1573;1574</NoWarn>
 
                <DefineConstants>DESIGN_MODE</DefineConstants>                          
                
@@ -44,7 +44,8 @@
                <PackageReference Include="System.Reflection.Emit.ILGeneration" Version="4.6.0" />
                <PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.6.0" />
        </ItemGroup>
-       <ItemGroup>
+    <ItemGroup>
+        <Content Include="$(SolutionDir)Images/crow.png" Pack="true" PackagePath="" />
                <Compile Include="src\**\*.cs" Exclude="src\Mono.Cairo\NativeMethods-internal.cs;src\backends\win32\User32\Structs\RawInputDevice.cs" />
                <EmbeddedResource Include="Templates\*.*">
                        <LogicalName>Crow.%(Filename).template</LogicalName>
@@ -52,4 +53,4 @@
                <EmbeddedResource Include="Default.style" />
                <EmbeddedResource Include="Icons\*.*" />
        </ItemGroup>
-</Project>
\ No newline at end of file
+</Project>
index c0121bec0a6aa3afd2e5fb703502acec4c4a4ec7..01558753a892ee1e34fee2d2b1408342b7ebb896 100644 (file)
@@ -1,28 +1,6 @@
-//
-// CrowThread.cs
+// Copyright (c) 2013-2020  Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
 //
-// Author:
-//       Jean-Philippe Bruyère <jp.bruyere@hotmail.com>
-//
-// Copyright (c) 2013-2017 Jean-Philippe Bruyère
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-// THE SOFTWARE.
+// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
 
 using System;
 using System.Threading;
@@ -55,8 +33,8 @@ namespace Crow
                public void Cancel(){
                        if (thread.IsAlive & !cancelRequested){
                                cancelRequested = true;
-                               Thread.Sleep (1);
-                               thread.Abort ();
+                               while (thread.IsAlive) 
+                                       Thread.Sleep (1);
                                thread.Join ();
                        }
                        lock (Host.IFace.CrowThreads)
index ee4f04c64ee29abe2c1e0185cd1623da7c8f7899..9a94d703f9d714e1e80b5175565eb723557f3e58 100644 (file)
@@ -474,11 +474,13 @@ namespace Crow
                /// <param name="path">path of the iml file to load</param>
                public Widget Load (string path)
                {
-                       lock (UpdateMutex) {
-                               Widget tmp = CreateInstance (path);
-                               AddWidget (tmp);
-                               return tmp;
-                       }
+                       Monitor.Enter (UpdateMutex); 
+
+                       Widget tmp = CreateInstance (path);
+                       AddWidget (tmp);
+
+                       Monitor.Exit (UpdateMutex);
+                       return tmp;
                }
                /// <summary>
                /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree
index 9546174e338f35ddf04af6f71cea47e8c2afde89..a4a955ffd0bb1622cd075632fcc3c6962aa3076e 100644 (file)
@@ -361,8 +361,24 @@ namespace Crow {
 //                     }
 //             }
                void cancelLoadingThread(){
-                       if (loadingThread != null)
-                               loadingThread.Cancel ();
+                       if (loadingThread == null)
+                               return;
+
+                       bool updateMx = Monitor.IsEntered (IFace.UpdateMutex);
+                       bool layoutMx = Monitor.IsEntered (IFace.LayoutMutex);
+
+                       if (layoutMx)
+                               Monitor.Exit (IFace.LayoutMutex);
+                       if (updateMx)
+                               Monitor.Exit (IFace.UpdateMutex);
+
+                       loadingThread.Cancel ();
+
+                       if (layoutMx)
+                               Monitor.Enter (IFace.LayoutMutex);
+                       if (updateMx)
+                               Monitor.Enter (IFace.UpdateMutex);
+
                }
                void loadPage(IEnumerable _data, Group page, string _dataTest)
                {
@@ -519,8 +535,8 @@ namespace Crow {
 
                protected override void Dispose (bool disposing)
                {
-                       if (disposing && loadingThread != null)
-                               loadingThread.Cancel ();
+                       if (disposing)
+                               cancelLoadingThread ();
                        base.Dispose (disposing);
                }
 
diff --git a/clean.sh b/clean.sh
new file mode 100755 (executable)
index 0000000..a556747
--- /dev/null
+++ b/clean.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+rm -fr build && find . -iname bin -o -iname obj -o -iname packages | xargs rm -rf