[ease] [editor] Fix async save of small sizes.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] [editor] Fix async save of small sizes.
- Date: Sat, 7 Aug 2010 21:01:47 +0000 (UTC)
commit 6fee5f1368e037cdf44ca7ce50c665c568ca1f33
Author: Nate Stedman <natesm gmail com>
Date: Sat Aug 7 16:27:27 2010 -0400
[editor] Fix async save of small sizes.
Saving would occasionally place the dialog on top
of the window permanently, when the thread destroying
the dialog finished before the dialog was actually
shown by GTK. This has been fixed.
Additionally, async saving is bypassed if the file is
below 5 MB.
ease-core/ease-archiver.vala | 26 +++++++++++++++-----------
ease-core/ease-dialog-progress.vala | 6 +++++-
2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/ease-core/ease-archiver.vala b/ease-core/ease-archiver.vala
index b45b123..e16e4b3 100644
--- a/ease-core/ease-archiver.vala
+++ b/ease-core/ease-archiver.vala
@@ -27,8 +27,12 @@ internal class Ease.Archiver : GLib.Object
private static GLib.List<Archiver> archivers = new GLib.List<Archiver>();
private const int ARCHIVE_BUFFER = 4096;
- private const string LABEL_MARKUP = "<large>%s</large>".printf(LABEL_TEXT);
- private const string LABEL_TEXT = _("Saving %s");
+ private const string LABEL_TEXT = _("Saving \"%s\"");
+
+ /**
+ * The minimum filesize at which asynchronous saving is used.
+ */
+ private const int ASYNC_SIZE = 1024 * 1024 * 5;
internal Archiver(string temp, string fname, Dialogs.Progress dlog)
{
@@ -37,14 +41,6 @@ internal class Ease.Archiver : GLib.Object
dialog = dlog;
archivers.append(this);
- if (!Thread.supported())
- {
- // fall back on non-async archiving
- async = false;
- archive_real();
- return;
- }
-
// this is a little redundant, probably not a huge perf hit though
recursive_directory(temp_path, null, (path, full_path) => {
Posix.Stat st;
@@ -52,7 +48,15 @@ internal class Ease.Archiver : GLib.Object
total_size += (int)st.st_size;
});
- dialog.set_label("Hello World");
+ if (!Thread.supported() || total_size < ASYNC_SIZE)
+ {
+ // fall back on non-async archiving
+ async = false;
+ archive_real();
+ return;
+ }
+
+ dialog.set_label(LABEL_TEXT.printf(filename));
dialog.show();
thread = Thread.create(archive_real, true);
}
diff --git a/ease-core/ease-dialog-progress.vala b/ease-core/ease-dialog-progress.vala
index 3f5fc0f..57755af 100644
--- a/ease-core/ease-dialog-progress.vala
+++ b/ease-core/ease-dialog-progress.vala
@@ -30,6 +30,7 @@ public class Ease.Dialogs.Progress : GLib.Object
private Gtk.Label label;
private Gtk.ProgressBar progress;
private double max_val;
+ private bool destroyed = false;
/**
* Creates a progress dialog.
@@ -68,7 +69,9 @@ public class Ease.Dialogs.Progress : GLib.Object
*/
public void show()
{
- dialog.show();
+ // we have to immediately show the dialog
+ // sometimes the thread might finish before it is shown
+ if (!destroyed) dialog.show_now();
}
/**
@@ -76,6 +79,7 @@ public class Ease.Dialogs.Progress : GLib.Object
*/
public void destroy()
{
+ destroyed = true;
dialog.destroy();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]