Skip to content

Commit

Permalink
FIX: Architect freezing (#2507)
Browse files Browse the repository at this point in the history
The code was redundant and it was causing Architect to freeze (calling log.Warn in BackgroundWorker caused LogPad to freeze). This was probably a bug in one of our dependencies.
  • Loading branch information
JindrichSusen committed Mar 6, 2024
1 parent b664d6c commit ab66c9f
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 1,198 deletions.
121 changes: 3 additions & 118 deletions backend/OrigamArchitect/ArchitectWorkbench.cs
Expand Up @@ -117,9 +117,7 @@ internal class frmMain : Form, IWorkbench
private static ICellStyle _dateCellStyle;
private string _configFilePath;
private FormWindowState lastWindowState;

public const string ORIGAM_COM_BASEURL = "https://origam.com/";
public const string ORIGAM_COM_API_BASEURL = "https://origam.com/web/";

public const bool IgnoreHTTPSErrors = false;


Expand All @@ -133,8 +131,6 @@ internal class frmMain : Form, IWorkbench
private PictureBox logoPictureBox;
private FlowLayoutPanel toolStripFlowLayoutPanel;
private Panel toolStripPanel;
private BackgroundWorker LicenseBackgroudExtender;
private BackgroundWorker AutoUpdateBackgroudFinder;
private TableLayoutPanel rightToolsTripLayoutPanel;
private ComboBox searchComboBox;

Expand Down Expand Up @@ -285,8 +281,6 @@ private void InitializeComponent()
this.toolStripPanel = new System.Windows.Forms.Panel();
this.rightToolsTripLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
this.searchComboBox = new System.Windows.Forms.ComboBox();
this.LicenseBackgroudExtender = new System.ComponentModel.BackgroundWorker();
this.AutoUpdateBackgroudFinder = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)(this.sbpText)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.sbpMemory)).BeginInit();
this.toolStripFlowLayoutPanel.SuspendLayout();
Expand Down Expand Up @@ -426,10 +420,6 @@ private void InitializeComponent()
this.searchComboBox.KeyDown += searchBox_KeyDown;
this.searchComboBox.Text = "Search";
//
// AutoUpdateBackgroudFinder
//
this.AutoUpdateBackgroudFinder.DoWork += new System.ComponentModel.DoWorkEventHandler(this.AutoUpdateBackgroundFinder_DoWork);
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
Expand Down Expand Up @@ -1875,15 +1865,7 @@ private void frmMain_Load(object sender, EventArgs e)
this.dockPanel.ContentRemoved += dockPanel_ContentRemoved;
this.dockPanel.ActiveContentChanged +=
dockPanel_ActiveContentChanged;



#if !ORIGAM_CLIENT
// auto-update within release-branch
AutoUpdateBackgroudFinder.RunWorkerAsync();
// search Origam.com for whether there is a newer architect version within the same release branch
// as the current branch
#endif

Connect();
splash.Dispose();
}
Expand Down Expand Up @@ -2492,104 +2474,7 @@ public void ExportToExcel(string name, ArrayList list)
sfd.Title = strings.ExcepExport_Title;
return sfd;
}

private void AutoUpdate()
{
System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

string url = null;
string newVersion = null;

// don't update if run from dev build (0.0.0.0) or from master build (0.0.0.x)
if ((version.Major == 0)
&& (version.Minor == 0)
&& (version.Build == 0))
{
return;
}

if (version.Major == 0)
{
url = string.Format("{0}{1}",
ORIGAM_COM_API_BASEURL,
"public/getSetupNewestBuildInMasterBranch");
}
else
{
/*
https://origam.com/public/getSetupNewestBuildInStableBranch?stableBranch=2016.3
*/
url = string.Format("{0}public/getSetupNewestBuildInStableBranch?stableBranch={1}.{2}",
ORIGAM_COM_API_BASEURL, version.Major, version.Minor);
}

try
{
using (WebResponse webResponse = HttpTools.Instance.GetResponse(url,
"GET", null, null,
new Hashtable()
{ { "Accept-Encoding", "gzip,deflate"} }
, null, null, null, 10000, null, IgnoreHTTPSErrors))
{
string output;
HttpWebResponse httpWebResponse = webResponse as HttpWebResponse;
output = HttpTools.Instance.ReadResponseTextRespectionContentEncoding(httpWebResponse);
JObject jResult = (JObject)JsonConvert.DeserializeObject(output);

int newestBuildVersion = int.Parse(((string)jResult["ROOT"]
["Releases_Build"][0]["BuildVersion"]));
string upgradeUrl = (string)jResult["ROOT"]["Releases_Build"][0]["Url"];

if (version.Major == 0)
{
newVersion = string.Format("0.0.0.{0}", newestBuildVersion);
}
else
{
newVersion = string.Format("{0}.{1}.{2}.0", version.Major,
version.Minor, newestBuildVersion);
}

if (newVersion.CompareTo(version.ToString()) > 0)
{

string message = string.Format(
strings.AutoUpdate_NewerVersionNotice,
newVersion, version.ToString());

string caption = strings.NewerVersion_Title;
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
// Displays the MessageBox.
result = MessageBox.Show(message, caption, buttons);

if (result == System.Windows.Forms.DialogResult.Yes)
{
System.Diagnostics.Process.Start(upgradeUrl);
// Closes the parent form.
this.Close();
}
}
}
}
catch (Exception)
{
// continue if auto-upgrade fails
}
}


private void AutoUpdateBackgroundFinder_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bw = sender as BackgroundWorker;
AutoUpdate();
e.Result = true;
if (bw.CancellationPending)
{
e.Cancel = true;
}
}


private static bool TestConnectionToApplicationDataDatabase()
{
AbstractSqlDataService abstractSqlDataService = DataServiceFactory.GetDataService() as AbstractSqlDataService;
Expand Down
162 changes: 0 additions & 162 deletions backend/OrigamArchitect/LoginForm.Designer.cs

This file was deleted.

0 comments on commit ab66c9f

Please sign in to comment.