Skip to content

Commit 2d7cb89

Browse files
committed
Fixed dispose and finalizing bugs that could cause crash
FIxed printing dialogs' size bug Fixed Binary_NET2 files because they were build for .NET Framework 4.0 instead of 2.0 Added new event: HTTPErrorOccured Minor bug fixes
1 parent 6ecde56 commit 2d7cb89

File tree

101 files changed

+11701
-11824
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+11701
-11824
lines changed

Diff for: Binary NET2/OpenWebKitSharp.dll

-31.5 KB
Binary file not shown.

Diff for: Binary/OpenWebKitSharp.dll

1.5 KB
Binary file not shown.

Diff for: JavaScript/JSCore.sdf

-28.1 MB
Binary file not shown.

Diff for: Source/OpenWebKitSharp/ActivationContext.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ public void Activate()
8383
throw new ObjectDisposedException(this.ToString());
8484
if (!Initialized)
8585
{
86-
Initialize();
87-
Activate();
86+
if (Initialize())
87+
Activate();
88+
else
89+
Dispose();
8890
}
8991
if (!Activated)
9092
{
@@ -122,7 +124,7 @@ public void Deactivate()
122124
/// <summary>
123125
/// Initializes the activation context.
124126
/// </summary>
125-
public void Initialize()
127+
public bool Initialize()
126128
{
127129
if (disposed)
128130
throw new ObjectDisposedException(this.ToString());
@@ -146,8 +148,10 @@ public void Initialize()
146148
read.Controls[0].Text = Properties.Resources.How_to_use;
147149
read.Text = "How to use.txt";
148150
read.Show();
151+
return false;
149152
}
150153
}
154+
return true;
151155
}
152156

153157
#region Garbage collection stuff

Diff for: Source/OpenWebKitSharp/DOMListener.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@ public void Dispose()
4343
{
4444
foreach (object o in todispose)
4545
{
46-
Marshal.Release(Marshal.GetComInterfaceForObject(o, typeof(IDOMEventListener)));
46+
try
47+
{
48+
Marshal.Release(Marshal.GetComInterfaceForObject(o, typeof(IDOMEventListener)));
49+
}
50+
catch { }
4751
}
52+
todispose.Clear();
4853
todispose = null;
4954
}
5055
void mu_Fired(object sender, EventArgs e)

Diff for: Source/OpenWebKitSharp/JSManagement.cs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System;
44
using System.Collections.Generic;
55
using System.Text;
6-
using System.Linq;
76
using WebKit.JSCore;
87
using System.Threading;
98
using WebKit.Interop;

Diff for: Source/OpenWebKitSharp/OpenWebKitSharp.csproj

+17-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
<RootNamespace>WebKit</RootNamespace>
1212
<AssemblyName>OpenWebKitSharp</AssemblyName>
1313
<FileAlignment>512</FileAlignment>
14-
<TargetFrameworkProfile />
14+
<TargetFrameworkProfile>
15+
</TargetFrameworkProfile>
16+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
1517
</PropertyGroup>
1618
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1719
<DebugSymbols>true</DebugSymbols>
@@ -43,8 +45,8 @@
4345
<Prefer32Bit>false</Prefer32Bit>
4446
<Optimize>false</Optimize>
4547
<DefineConstants>DEBUG</DefineConstants>
46-
<DebugType>pdbonly</DebugType>
47-
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
48+
<DebugType>full</DebugType>
49+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
4850
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
4951
<DebugSymbols>true</DebugSymbols>
5052
<UseVSHostingProcess>false</UseVSHostingProcess>
@@ -71,7 +73,8 @@
7173
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
7274
<WarningLevel>4</WarningLevel>
7375
<Optimize>false</Optimize>
74-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
76+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
77+
<Prefer32Bit>false</Prefer32Bit>
7578
</PropertyGroup>
7679
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug_NET2|x86'">
7780
<DebugSymbols>true</DebugSymbols>
@@ -82,7 +85,8 @@
8285
<PlatformTarget>x86</PlatformTarget>
8386
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
8487
<DebugType>full</DebugType>
85-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
88+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
89+
<Prefer32Bit>false</Prefer32Bit>
8690
</PropertyGroup>
8791
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_NET2|AnyCPU'">
8892
<OutputPath>bin\Release_NET2\</OutputPath>
@@ -94,7 +98,8 @@
9498
<ErrorReport>prompt</ErrorReport>
9599
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
96100
<WarningLevel>4</WarningLevel>
97-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
101+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
102+
<Prefer32Bit>false</Prefer32Bit>
98103
</PropertyGroup>
99104
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_NET2|x86'">
100105
<OutputPath>..\..\Build_NET2\</OutputPath>
@@ -111,12 +116,16 @@
111116
<DefineConstants>LINUX</DefineConstants>
112117
<OutputPath>..\..\Linux\Debug\</OutputPath>
113118
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
119+
<Prefer32Bit>false</Prefer32Bit>
120+
<DebugType>full</DebugType>
121+
<DebugSymbols>true</DebugSymbols>
114122
</PropertyGroup>
115123
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release_Linux|x86'">
116124
<DefineConstants>LINUX</DefineConstants>
117125
<PlatformTarget>AnyCPU</PlatformTarget>
118126
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
119127
<OutputPath>..\..\Linux\Release\</OutputPath>
128+
<Prefer32Bit>false</Prefer32Bit>
120129
</PropertyGroup>
121130
<ItemGroup>
122131
<Reference Include="atk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
@@ -345,9 +354,6 @@
345354
<None Include="app.config" />
346355
<None Include="How to use.txt" />
347356
<Content Include="Important! Please Read!.txt" />
348-
<Content Include="OpenWebKitSharp.manifest">
349-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
350-
</Content>
351357
<None Include="Properties\Settings.settings">
352358
<Generator>PublicSettingsSingleFileGenerator</Generator>
353359
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -369,13 +375,15 @@ del temp_exclude_files.txt</PostBuildEvent>
369375
<OutputPath>bin\Debug_Linux</OutputPath>
370376
<WarningLevel>4</WarningLevel>
371377
<DefineConstants>LINUX</DefineConstants>
378+
<Prefer32Bit>false</Prefer32Bit>
372379
</PropertyGroup>
373380
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Linux|AnyCPU' ">
374381
<DebugType>none</DebugType>
375382
<Optimize>false</Optimize>
376383
<OutputPath>bin\Release_Linux</OutputPath>
377384
<WarningLevel>4</WarningLevel>
378385
<DefineConstants>LINUX</DefineConstants>
386+
<Prefer32Bit>false</Prefer32Bit>
379387
</PropertyGroup>
380388
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
381389
Other similar extension points exist, see Microsoft.Common.targets.

Diff for: Source/OpenWebKitSharp/OpenWebKitSharp.manifest

+1-1
Large diffs are not rendered by default.

Diff for: Source/OpenWebKitSharp/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.0.0.0000")]
36-
[assembly: AssemblyFileVersion("3.0.0.0000")]
35+
[assembly: AssemblyVersion("3.0.1.0023")]
36+
[assembly: AssemblyFileVersion("3.0.1.0023")]

Diff for: Source/OpenWebKitSharp/WebKitBrowser.cs

+38-4
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929

3030

3131
// credits to VBCoder for updated favicon code
32+
// credits to Vincent Richomme for building the modified WebKit build that is used by OpenWebKitSharp 3.0 and newer
3233

33-
// TODO: dispose / finalize stuff
34-
// design time support for properties etc..
34+
// thanks to the guy from the issue 124 (http://code.google.com/p/open-webkit-sharp/issues/detail?id=124)
35+
// for providing a fix to the printing dialog bugs
3536

3637
using System;
3738
using System.Collections.Generic;
@@ -427,6 +428,11 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
427428
/// </summary>
428429
public event FileDownloadBeginEventHandler DownloadBegin = delegate { };
429430

431+
/// <summary>
432+
/// Occurs when an HTTP error occurs during navigation
433+
/// </summary>
434+
public event HTTPErrorEventHandler HTTPErrorOccured = delegate { };
435+
430436
/// <summary>
431437
/// Occurs when a form is submitted.
432438
/// </summary>
@@ -1626,7 +1632,13 @@ private void frameLoadDelegate_DidStartProvisionalLoadForFrame(WebView WebView,
16261632
if (!string.IsNullOrEmpty(url))
16271633
{
16281634
BackgroundWorker bw = new BackgroundWorker();
1635+
bw.RunWorkerCompleted += delegate (object s, RunWorkerCompletedEventArgs e) { if (e.Result != null && e.Result.GetType().Equals(typeof(WebException)))
1636+
{
1637+
HTTPErrorOccured(this, new HTTPErrorEventArgs() { WebException = (WebException)e.Result });
1638+
}};
1639+
16291640
bw.DoWork += new DoWorkEventHandler(bw_DoWork);
1641+
16301642
HeadersAvailableEventArgs h = new HeadersAvailableEventArgs(new Uri(frame.provisionalDataSource().request().url()), frame.provisionalDataSource().request());
16311643
bw.RunWorkerAsync(h);
16321644
string Url = h.Url.ToString();
@@ -1651,7 +1663,8 @@ private void frameLoadDelegate_DidStartProvisionalLoadForFrame(WebView WebView,
16511663
}
16521664
}
16531665
}
1654-
}
1666+
1667+
}
16551668
private WebMutableURLRequestClass currentreq { get; set; }
16561669
void bw_DoWork(object sender, DoWorkEventArgs e)
16571670
{
@@ -1674,7 +1687,10 @@ void bw_DoWork(object sender, DoWorkEventArgs e)
16741687
WebRequestObject = null;
16751688
ResponseObject = null;
16761689
}
1677-
catch { }
1690+
catch (WebException ex) // thanks to: http://code.google.com/p/open-webkit-sharp/issues/detail?id=146
1691+
{
1692+
e.Result = ex;
1693+
}
16781694
}
16791695

16801696
private void frameLoadDelegate_DidFinishLoadForFrame(WebView WebView, IWebFrame frame)
@@ -2187,6 +2203,11 @@ public void ShowPageSetupDialog()
21872203
br.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(br_DocumentCompleted);
21882204
br.Tag = "PageSetup";
21892205
System.IO.File.WriteAllText(Application.StartupPath + @"\owstemp.html", DocumentText);
2206+
br.Visible = false;
2207+
2208+
// must be set because of position & size depend on Parent Control's position & size.
2209+
if (Parent != null)
2210+
Parent.Controls.Add(br);
21902211
br.Navigate(Application.StartupPath + @"\owstemp.html");
21912212
}
21922213

@@ -2200,6 +2221,11 @@ public void ShowPrintDialog()
22002221
br.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(br_DocumentCompleted);
22012222
br.Tag = "PrintDlg";
22022223
System.IO.File.WriteAllText(Application.StartupPath + @"\owstemp.html", DocumentText);
2224+
br.Visible = false;
2225+
2226+
// must be set because of position & size depend on Parent Control's position & size.
2227+
if (Parent != null)
2228+
Parent.Controls.Add(br);
22032229
br.Navigate(Application.StartupPath + @"\owstemp.html");
22042230
}
22052231

@@ -2219,6 +2245,9 @@ void br_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
22192245
s.Print();
22202246
if (c == "PageSetup")
22212247
s.ShowPageSetupDialog();
2248+
if (s.Parent != null)
2249+
if (s.Controls.Contains(s))
2250+
s.Parent.Controls.Remove(s);
22222251
s.Dispose();
22232252
if (File.Exists(Application.StartupPath + @"\owstemp.html"))
22242253
File.Delete(Application.StartupPath + @"\owstemp.html");
@@ -2235,6 +2264,11 @@ public void ShowPrintPreviewDialog()
22352264
br.Tag = "PrintPreviewDlg";
22362265
System.IO.File.WriteAllText(Application.StartupPath + @"\owstemp.html", DocumentText);
22372266
br.Navigate(Application.StartupPath + @"\owstemp.html");
2267+
br.Visible = false;
2268+
2269+
// must be set because of position & size depend on Parent Control's position & size.
2270+
if (Parent != null)
2271+
Parent.Controls.Add(br);
22382272
}
22392273

22402274
public GlobalPreferences Preferences

Diff for: Source/OpenWebKitSharp/WebKitBrowser.designer.cs

+2-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Source/OpenWebKitSharp/WebKitBrowserEvents.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ namespace WebKit
115115
/// <param name="sender">The source of the event.</param>
116116
/// <param name="e">A ShowJavaScriptPromptPanelEventArgs that contains the event data.</param>
117117
public delegate void ShowJavaScriptPromptPanelEventHandler(object sender, ShowJavaScriptPromptPanelEventArgs e);
118-
118+
public delegate void HTTPErrorEventHandler(object sender, HTTPErrorEventArgs e);
119119
public delegate void CanGoBackChanged(object sender, CanGoBackChangedEventArgs e);
120120
public delegate void CanGoForwardChanged(object sender, CanGoForwardChangedEventArgs e);
121121
public delegate void MouseDidMoveOverElementEventHandler(object sender, MouseDidMoveOverElementEventArgs e);
@@ -124,7 +124,10 @@ namespace WebKit
124124
#endregion
125125

126126
#region EventArgs classes
127-
127+
public class HTTPErrorEventArgs : EventArgs
128+
{
129+
public WebException WebException { get; internal set; }
130+
}
128131
public class GeolocationRequestEventArgs : EventArgs
129132
{
130133
public bool Allow { get; set; }

Diff for: Source/OpenWebKitSharp/app.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
</setting>
1919
</WebKit.Properties.Settings>
2020
</userSettings>
21-
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
21+
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

0 commit comments

Comments
 (0)