Conditionally compile out the 'single threaded' stuff. It doesn't work very well...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 23 Feb 2008 01:25:23 +0000 (01:25 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 23 Feb 2008 01:25:23 +0000 (01:25 +0000)
git-svn-id: http://svn.voria.com/code@1801 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/gtkmm/app.cpp
synfig-studio/trunk/src/gtkmm/app.h
synfig-studio/trunk/src/gtkmm/asyncrenderer.cpp
synfig-studio/trunk/src/gtkmm/asyncrenderer.h
synfig-studio/trunk/src/gtkmm/canvasview.cpp
synfig-studio/trunk/src/gtkmm/dialog_setup.cpp
synfig-studio/trunk/src/gtkmm/dialog_setup.h
synfig-studio/trunk/src/gtkmm/dock_navigator.cpp
synfig-studio/trunk/src/gtkmm/preview.cpp
synfig-studio/trunk/src/gtkmm/workarea.cpp
synfig-studio/trunk/src/gtkmm/workarea.h

index 1da982b..762e46a 100644 (file)
@@ -261,7 +261,9 @@ studio::Dock_Curves* dock_curves;
 std::list< etl::handle< studio::Module > > module_list_;
 
 bool studio::App::use_colorspace_gamma=true;
+#ifdef SINGLE_THREADED
 bool studio::App::single_threaded=false;
+#endif
 bool studio::App::restrict_radius_ducks=false;
 String studio::App::browser_command("firefox");
 
@@ -474,11 +476,13 @@ public:
                        value=strprintf("%s",Distance::system_name(App::distance_system).c_str());
                        return true;
                }
+#ifdef SINGLE_THREADED
                if(key=="single_threaded")
                {
                        value=strprintf("%i",(int)App::single_threaded);
                        return true;
                }
+#endif
                if(key=="auto_recover_backup_interval")
                {
                        value=strprintf("%i",App::auto_recover->get_timeout());
@@ -544,12 +548,14 @@ public:
                        App::distance_system=Distance::ident_system(value);;
                        return true;
                }
+#ifdef SINGLE_THREADED
                if(key=="single_threaded")
                {
                        int i(atoi(value.c_str()));
                        App::single_threaded=i;
                        return true;
                }
+#endif
                if(key=="restrict_radius_ducks")
                {
                        int i(atoi(value.c_str()));
@@ -573,7 +579,9 @@ public:
                ret.push_back("distance_system");
                ret.push_back("file_history.size");
                ret.push_back("use_colorspace_gamma");
+#ifdef SINGLE_THREADED
                ret.push_back("single_threaded");
+#endif
                ret.push_back("auto_recover_backup_interval");
                ret.push_back("restrict_radius_ducks");
                ret.push_back("browser_command");
@@ -1476,7 +1484,9 @@ App::reset_initial_window_configuration()
        synfigapp::Main::settings().set_value("dock.dialog.2.size","1045 235");
        synfigapp::Main::settings().set_value("pref.distance_system","pt");
        synfigapp::Main::settings().set_value("pref.use_colorspace_gamma","1");
+#ifdef SINGLE_THREADED
        synfigapp::Main::settings().set_value("pref.single_threaded","0");
+#endif
        synfigapp::Main::settings().set_value("pref.restrict_radius_ducks","0");
        synfigapp::Main::settings().set_value("window.toolbox.pos","4 4");
 }
index 103ce0d..dd823dd 100644 (file)
@@ -191,7 +191,9 @@ public:
 
        static bool use_colorspace_gamma;
 
+#ifdef SINGLE_THREADED
        static bool single_threaded;
+#endif
 
        static bool restrict_radius_ducks;
 
index ca7de13..72a286c 100644 (file)
@@ -211,8 +211,10 @@ public:
 
        virtual void end_frame()
        {
+#ifdef SINGLE_THREADED
                if (!single_threaded())
                {
+#endif
                        while(alive_flag)
                        {
                                Glib::Mutex::Lock lock(mutex);
@@ -224,7 +226,9 @@ public:
                                else
                                        break;
                        }
+#ifdef SINGLE_THREADED
                }
+#endif
                Glib::Mutex::Lock lock(mutex);
                if(!alive_flag)
                        return;
@@ -316,9 +320,11 @@ public:
 #endif
                }
 
+#ifdef SINGLE_THREADED
                if (single_threaded())
                        signal_progress()();
                else
+#endif
                        while(alive_flag && !ready_next)
                        {
                                Glib::Mutex::Lock lock(mutex);
@@ -345,7 +351,10 @@ public:
                Glib::Mutex::Lock lock(mutex);
                if(alive_flag)
                        alive_flag=warm_target->add_frame(&surface);
-               if (!single_threaded()) cond_frame_queue_empty.signal();
+#ifdef SINGLE_THREADED
+               if (!single_threaded())
+#endif
+                       cond_frame_queue_empty.signal();
                ready_next=true;
        }
 };
@@ -359,8 +368,10 @@ public:
 AsyncRenderer::AsyncRenderer(etl::handle<synfig::Target> target_,synfig::ProgressCallback *cb):
        error(false),
        success(false),
-       cb(cb),
-       updating(false)
+       cb(cb)
+#ifdef SINGLE_THREADED
+       , updating(false)
+#endif
 {
        render_thread=0;
        if(etl::handle<synfig::Target_Tile>::cast_dynamic(target_))
@@ -405,7 +416,10 @@ AsyncRenderer::stop()
                        signal_stop_();
 
 #if REJOIN_ON_STOP
-                       if (!single_threaded()) render_thread->join();
+#ifdef SINGLE_THREADED
+                       if (!single_threaded())
+#endif
+                               render_thread->join();
 #endif
 
                        // Make sure all the dispatch crap is cleared out
@@ -444,6 +458,7 @@ AsyncRenderer::start()
        );
 }
 
+#ifdef SINGLE_THREADED
 void
 AsyncRenderer::rendering_progress()
 {
@@ -451,6 +466,7 @@ AsyncRenderer::rendering_progress()
        while(studio::App::events_pending()) studio::App::iteration(false);
        updating = false;
 }
+#endif
 
 void
 AsyncRenderer::start_()
@@ -462,6 +478,7 @@ AsyncRenderer::start_()
                done_connection=signal_done_.connect(mem_fun(*this,&AsyncRenderer::stop));
 #endif
 
+#ifdef SINGLE_THREADED
                if (single_threaded())
                {
                        synfig::info("%s:%d rendering in the same thread", __FILE__, __LINE__);
@@ -470,6 +487,7 @@ AsyncRenderer::start_()
                        render_target();
                }
                else
+#endif
                {
                        render_thread=Glib::Thread::create(
                                sigc::mem_fun(*this,&AsyncRenderer::render_target),
index 9d19fd6..6678e4e 100644 (file)
 
 /* === M A C R O S ========================================================= */
 
-#define single_threaded()      App::single_threaded
-#define NotLock Glib::NOT_LOCK
+// uncomment to use a single thread, and hopefully get more stability
+// #define SINGLE_THREADED
+#ifdef SINGLE_THREADED
+#  define single_threaded()    App::single_threaded
+#endif
 
 /* === T Y P E D E F S ===================================================== */
 
@@ -87,13 +90,14 @@ public:
        void stop();
        void pause();
        void resume();
+#ifdef SINGLE_THREADED
        void rendering_progress();
+       bool updating;
+#endif
 
        bool has_error()const { return error; }
        bool has_success()const { return success; }
 
-       bool updating;
-
        sigc::signal<void>& signal_finished() { return signal_finished_; }
        sigc::signal<void>& signal_success() { return signal_success_; }
 
index 31d3153..84b0f45 100644 (file)
@@ -2004,6 +2004,7 @@ static bool _close_instance(etl::handle<Instance> instance)
 bool
 CanvasView::close_instance()
 {
+#ifdef SINGLE_THREADED
        if (get_work_area()->get_updating())
        {
                get_work_area()->stop_updating(true); // stop and mark as cancelled
@@ -2014,6 +2015,7 @@ CanvasView::close_instance()
                        250);
        }
        else
+#endif
                Glib::signal_timeout().connect(
                        sigc::bind(sigc::ptr_fun(_close_instance),
                                           (etl::handle<Instance>)get_instance()),
index 97fe0b0..4944f57 100644 (file)
@@ -77,7 +77,9 @@ Dialog_Setup::Dialog_Setup():
        adj_recent_files(15,1,50,1,1,1),
        adj_undo_depth(100,10,5000,1,1,1),
        toggle_use_colorspace_gamma(_("Visually Linear Color Selection")),
+#ifdef SINGLE_THREADED
        toggle_single_threaded(_("Use Only a Single Thread")),
+#endif
        toggle_restrict_radius_ducks(_("Restrict Real-Valued Ducks to Top Right Quadrant"))
 {
        // Setup the buttons
@@ -191,15 +193,17 @@ Dialog_Setup::Dialog_Setup():
        // Misc - use_colorspace_gamma
        misc_table->attach(toggle_use_colorspace_gamma, 0, 2, 5, 6, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
 
+#ifdef SINGLE_THREADED
        // Misc - single_threaded
-       misc_table->attach(toggle_single_threaded, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       misc_table->attach(toggle_single_threaded, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+#endif
 
        // Misc - auto backup interval
        attach_label(misc_table, _("Auto Backup Interval (0 to disable)"), 3, xpadding, ypadding);
        misc_table->attach(auto_backup_interval, 1, 2, 3, 4, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
 
        // Misc - restrict_radius_ducks
-       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 7, 8, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
+       misc_table->attach(toggle_restrict_radius_ducks, 0, 2, 6, 7, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, xpadding, ypadding);
 
        // Misc - browser_command
        attach_label(misc_table, _("Browser Command"), 4, xpadding, ypadding);
@@ -232,8 +236,10 @@ Dialog_Setup::on_apply_pressed()
        // Set the use_colorspace_gamma flag
        App::use_colorspace_gamma=toggle_use_colorspace_gamma.get_active();
 
+#ifdef SINGLE_THREADED
        // Set the single_threaded flag
        App::single_threaded=toggle_single_threaded.get_active();
+#endif
 
        // Set the auto backup interval
        App::auto_recover->set_timeout(auto_backup_interval.get_value() * 1000);
@@ -319,8 +325,10 @@ Dialog_Setup::refresh()
        // Refresh the status of the use_colorspace_gamma flag
        toggle_use_colorspace_gamma.set_active(App::use_colorspace_gamma);
 
+#ifdef SINGLE_THREADED
        // Refresh the status of the single_threaded flag
        toggle_single_threaded.set_active(App::single_threaded);
+#endif
 
        // Refresh the value of the auto backup interval
        auto_backup_interval.set_value(App::auto_recover->get_timeout() / 1000);
index 1c5338c..22dd512 100644 (file)
@@ -164,7 +164,9 @@ class Dialog_Setup : public Gtk::Dialog
        Gtk::Adjustment adj_undo_depth;
 
        Gtk::CheckButton toggle_use_colorspace_gamma;
+#ifdef SINGLE_THREADED
        Gtk::CheckButton toggle_single_threaded;
+#endif
 
        synfig::Time::Format time_format;
 
index 7141fa9..62a18c3 100644 (file)
@@ -259,10 +259,12 @@ static double zoom_to_unit(double f)
 
 bool studio::Widget_NavView::on_expose_draw(GdkEventExpose */*exp*/)
 {
+#ifdef SINGLE_THREADED
        // don't redraw if the previous redraw is still running single-threaded
        // or we end up destroying the renderer that's rendering it
        if (App::single_threaded && renderer && renderer->updating)
                return false;
+#endif
 
        //print out the zoom
        //HACK kind of...
index 74a0f8f..d681d3e 100644 (file)
@@ -867,9 +867,11 @@ void studio::Widget_Preview::stoprender()
                if (!preview->renderer)
                        return;
 
+#ifdef SINGLE_THREADED
                if (preview->renderer->updating)
                        preview->renderer->stop();
                else
+#endif
                        preview->renderer.detach();
        }
 }
index af6f2f3..c4f8be6 100644 (file)
@@ -828,18 +828,22 @@ WorkArea::~WorkArea()
                render_idle_func_id=0;
 }
 
+#ifdef SINGLE_THREADED
 bool
 WorkArea::get_updating()const
 {
        return App::single_threaded && async_renderer && async_renderer->updating;
 }
+#endif
 
+#ifdef SINGLE_THREADED
 void
 WorkArea::stop_updating(bool cancel)
 {
        async_renderer->stop();
        if (cancel) canceled_=true;
 }
+#endif
 
 void
 WorkArea::save_meta_data()
@@ -2216,12 +2220,14 @@ public:
 bool
 studio::WorkArea::async_update_preview()
 {
+#ifdef SINGLE_THREADED
        if (get_updating())
        {
                stop_updating();
                queue_render_preview();
                return false;
        }
+#endif
 
        async_renderer=0;
 
index 872d5fd..6e5ab7f 100644 (file)
@@ -259,8 +259,10 @@ public:
        bool get_canceled()const { return canceled_; }
        bool get_queued()const { return queued; }
        bool get_rendering()const { return rendering; }
+#ifdef SINGLE_THREADED
        bool get_updating()const;
        void stop_updating(bool cancel = false);
+#endif
        bool get_full_frame()const { return full_frame; }
        //int get_w()const { return w; }
        //int get_h()const { return h; }