[chronojump] Fixing windows hang on exit when cancelled chronopic
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixing windows hang on exit when cancelled chronopic
- Date: Tue, 19 Apr 2011 19:32:25 +0000 (UTC)
commit 7a166f297c847b7dd13fb04997786e44004e42b6
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Apr 19 21:31:01 2011 +0200
Fixing windows hang on exit when cancelled chronopic
glade/chronojump.glade | 3 +--
src/gui/chronojump.cs | 19 +++++++++++++++++++
src/gui/chronopic.cs | 29 ++++++++++++++++++++++++-----
src/gui/helpPorts.cs | 12 ++++++------
src/gui/person.cs | 7 ++++++-
5 files changed, 56 insertions(+), 14 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7ccd10c..864ee15 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -5525,7 +5525,6 @@ suitable for agility tests)</property>
<property name="spacing">10</property>
<child>
<widget class="GtkLabel" id="label205">
- <property name="visible">True</property>
<property name="label" translatable="yes">This dialog explains which ports are suitable to be connected with Chronopic</property>
<property name="wrap">True</property>
</widget>
@@ -5630,7 +5629,7 @@ suitable for agility tests)</property>
</child>
<child>
<widget class="GtkButton" id="button_force_port">
- <property name="label" translatable="yes">Force Chronopic port to COM1 or COM2</property>
+ <property name="label" translatable="yes">Force Chronopic port to COM1 - COM4</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 3afcd99..89c4928 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -372,6 +372,8 @@ public partial class ChronoJumpWindow
private bool normalGUI; //false means small gui
+ int chronopicCancelledTimes = 0;
+
//const int statusbarID = 1;
@@ -2098,6 +2100,15 @@ public partial class ChronoJumpWindow
//Log.End();
//Log.Delete();
Log.WriteLine("Bye3!");
+
+ if(chronopicCancelledTimes > 0 && Util.IsWindows()) {
+ new DialogMessage(Constants.MessageTypes.WARNING,
+ Catalog.GetString("Attention, current version of Chronojump gets hanged on exit\nif user has cancelled detection of Chronopic.") + "\n\n" +
+ Catalog.GetString("Sorry, you will have to close Chronojump using CTRL + ALT + DEL."));
+ }
+
+ Log.WriteLine("Bye4!");
+
Application.Quit();
}
@@ -3878,7 +3889,9 @@ Console.WriteLine("X");
ChronopicPortData a = new ChronopicPortData(i,"",false);
cpd.Add(a);
}
+
chronopicWin = ChronopicWindow.Create(cpd, recreate, volumeOn);
+ chronopicWin.FakeButtonCancelled.Clicked += new EventHandler(on_chronopic_window_cancelled);
chronopicLabels(0);
}
@@ -3888,6 +3901,12 @@ Console.WriteLine("X");
chronopicWin.FakeWindowDone.Clicked += new EventHandler(on_chronopic_window_connected_or_done);
}
+
+ private void on_chronopic_window_cancelled (object o, EventArgs ags) {
+ chronopicWin.FakeButtonCancelled.Clicked -= new EventHandler(on_chronopic_window_cancelled);
+ chronopicCancelledTimes ++;
+ }
+
/*
private void chronopicWindowReload(object o, EventArgs args) {
//chronopicWin.FakeWindowReload.Clicked -= new EventHandler(chronopicWindowReload);
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 8ab63bd..1e28df2 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -88,6 +88,7 @@ public class ChronopicWindow
bool needUpdateChronopicWin;
bool updateChronopicWinValuesState;
string updateChronopicWinValuesMessage;
+ Gtk.Button fakeButtonCancelled;
[Widget] Gtk.Button fakeConnectionButton; //raised when chronopic detection ended
[Widget] Gtk.Button fakeWindowDone; //raised when chronopic detection ended
@@ -234,6 +235,8 @@ Log.WriteLine("bbb");
image_cp2_yes.Hide();
image_cp3_yes.Hide();
image_cp4_yes.Hide();
+
+ fakeButtonCancelled = new Gtk.Button();
}
//check if user has disconnected chronopic or port has changed
@@ -402,7 +405,7 @@ Log.WriteLine("bbb");
saferPorts =
"\n\n" + Catalog.GetString("COM3 use to be the correct port (if available).") + "\n" +
Catalog.GetString("Ports above COM4 may not work.") + "\n" +
- Catalog.GetString("If you want a safer port, press help button and press 'Force Chronopic to port COM1 or COM2'.");
+ Catalog.GetString("If you want a safer port, press help button and press 'Force Chronopic to port COM1 - COM4'.");
textview_ports_found.Buffer = UtilGtk.TextViewPrint(
Util.StringArrayToString(SerialPort.GetPortNames(),"\n"));
@@ -429,7 +432,7 @@ Log.WriteLine("bbb");
return false;
}
//need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
- ChronopicConnection chronopicConnectionWin = ChronopicConnection.Show();
+ chronopicConnectionWin = ChronopicConnection.Show();
chronopicConnectionWin.Pulse();
Thread.Sleep (50);
@@ -575,10 +578,11 @@ Log.WriteLine("bbb");
void prepareChronopicConnection() {
- ChronopicConnection chronopicConnectionWin = ChronopicConnection.Show();
+ //ChronopicConnection chronopicConnectionWin = ChronopicConnection.Show();
+ chronopicConnectionWin = ChronopicConnection.Show();
chronopicConnectionWin.LabelFeedBackReset();
- chronopicConnectionWin.Button_cancel.Clicked += new EventHandler(on_chronopic_cancelled);
+// chronopicConnectionWin.Button_cancel.Clicked += new EventHandler(on_chronopic_cancelled);
fakeConnectionButton = new Gtk.Button();
fakeConnectionButton.Clicked += new EventHandler(on_chronopic_detection_ended);
@@ -590,6 +594,8 @@ Log.WriteLine("bbb");
protected void waitChronopicStart ()
{
+ chronopicConnectionWin.Button_cancel.Clicked += new EventHandler(on_chronopic_cancelled);
+
if(currentCp == 1) {
// simulated = false;
// SqlitePreferences.Update("simulated", simulated.ToString(), false);
@@ -726,9 +732,19 @@ Log.WriteLine("bbb");
private void on_chronopic_cancelled (object o, EventArgs args) {
Log.WriteLine("cancelled-----");
+ fakeButtonCancelled.Click(); //just to show message of crashing on windows exiting
//kill the chronopicInit function that is waiting event
- thread.Abort();
+ //thread.Abort();
+ //http://stackoverflow.com/questions/2853072/thread-does-not-abort-on-application-closing
+ //Log.Write(thread.ThreadState.ToString());
+ thread.IsBackground = true;
+
+ //try to solve windows problems when a chronopic detection was cancelled
+ //Log.Write(thread.ThreadState.ToString());
+ //thread.Join(1000);
+ //Log.Write(thread.ThreadState.ToString());
+
updateChronopicWinValuesState= false; //disconnected
updateChronopicWinValuesMessage= Catalog.GetString("Cancelled by user");
@@ -807,5 +823,8 @@ Log.WriteLine("bbb");
}
*/
+ public Gtk.Button FakeButtonCancelled {
+ get { return fakeButtonCancelled; }
+ }
}
diff --git a/src/gui/helpPorts.cs b/src/gui/helpPorts.cs
index 394cf1f..ec02923 100644
--- a/src/gui/helpPorts.cs
+++ b/src/gui/helpPorts.cs
@@ -76,8 +76,8 @@ public class HelpPorts
label_detected.UseMarkup = true;
label_manual.Text =
- Catalog.GetString("More information on <b>Chronojump Manual</b> at section:") + " <b>4.6</b>\n" +
- "<i>" + Path.GetFullPath(Util.GetManualDir()) + "</i>\n" +
+ Catalog.GetString("More information on <b>Chronojump Manual</b>") + "\n" +
+ "<i>" + Path.GetFullPath(Util.GetManualDir()) + "</i>\n\n" +
Catalog.GetString("Newer versions will be on this site:") +"\n" +
"<i>http://chronojump.org/documents.html</i>";
label_manual.UseMarkup = true;
@@ -96,20 +96,20 @@ public class HelpPorts
"4 " + Catalog.GetString("Select <i>administrate dispositives</i>. It's first button.") + "\n" +
"5 " + Catalog.GetString("Click on the '+' at left of COM and LPT ports.") + "\n" +
"6 " + Catalog.GetString("The port name will be what it's written like COM? on the USB-serial line.") + "\n" + " " + Catalog.GetString("Eg: if it's written COM7, then you should write COM7 at Chronopic window.") + "\n\n" +
- Catalog.GetString("If it doesn't work, try to force to COM1 or COM2, as it's explained on parent window.")
+ Catalog.GetString("If it doesn't work, try to force to COM1 - COM4, as it's explained on parent window.")
);
}
private void on_button_force_port_clicked (object o, EventArgs args)
{
new DialogMessage(Constants.MessageTypes.HELP,
- Catalog.GetString("Force Chronopic port to COM1 or COM2") + "\n\n" +
+ Catalog.GetString("Force Chronopic port to COM1 - COM4") + "\n\n" +
"1 " + Catalog.GetString("Find the port as explained at <i>Check Chronopic port</i>.") + "\n" +
"2 " + Catalog.GetString("At the line where port is shown right click and select <i>properties</i> (last option).") + "\n" +
"3 " + Catalog.GetString("Go to <i>Port configurations</i>.") + "\n" +
"4 " + Catalog.GetString("Go to <i>Advanced options</i>.") + "\n" +
- "5 " + Catalog.GetString("Select COM1 or COM2 on the list shown on that window.") + "\n" +
- Catalog.GetString("If COM1 and COM2 are <i>used</i>, then select unused ports below 10.") + "\n" + Catalog.GetString("If doesn't work, try to select the COM1 or COM2 (normally they are not really <i>used</i>).")
+ "5 " + Catalog.GetString("Select COM1, COM2, COM3 or COM4 on the list shown on that window.") + "\n" +
+ Catalog.GetString("If COM1 - COM4 are <i>used</i>, then select unused ports below 10.") + "\n" + Catalog.GetString("If doesn't work, try to select the COM1 - COM4 (normally they are not really <i>used</i>).")
);
}
diff --git a/src/gui/person.cs b/src/gui/person.cs
index 0fc8e22..64efe7b 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -1001,9 +1001,12 @@ public class PersonAddModifyWindow
capturerWindow = new Gtk.Window("Capturer");
capturerWindow.Add(capturer);
capturerWindow.Modal=true;
+
+ person_win.Hide();
+
capturerWindow.ShowAll();
capturerWindow.Present();
- capturerWindow.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose();};
+ capturerWindow.DeleteEvent += delegate(object sender, DeleteEventArgs e) {capturer.Close(); capturer.Dispose(); person_win.Show(); };
capturer.Run();
}
@@ -1034,6 +1037,8 @@ public class PersonAddModifyWindow
capturer.Dispose();
capturerWindow.Hide();
+ person_win.Show();
+
string tempFileName = Path.Combine(Path.GetTempPath(), Constants.PhotoSmallTemp +
Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]