summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/LoadGraphWindow.cpp8
-rw-r--r--src/gui/ThreadedLoader.cpp21
-rw-r--r--src/gui/ThreadedLoader.hpp9
3 files changed, 19 insertions, 19 deletions
diff --git a/src/gui/LoadGraphWindow.cpp b/src/gui/LoadGraphWindow.cpp
index 10ddf436..b02ca510 100644
--- a/src/gui/LoadGraphWindow.cpp
+++ b/src/gui/LoadGraphWindow.cpp
@@ -88,9 +88,9 @@ LoadGraphWindow::LoadGraphWindow(BaseObjectType* cobject,
property_select_multiple() = true;
// Add global examples directory to "shortcut folders" (bookmarks)
- const std::string examples_dir = Ingen::data_file_path("graphs");
+ const FilePath examples_dir = Ingen::data_file_path("graphs");
if (Glib::file_test(examples_dir, Glib::FILE_TEST_IS_DIR)) {
- add_shortcut_folder(examples_dir);
+ add_shortcut_folder(examples_dir.string());
}
}
@@ -175,7 +175,7 @@ LoadGraphWindow::ok_clicked()
}
_app->loader()->load_graph(
- true, get_filename(), parent, symbol, _initial_data);
+ true, FilePath(get_filename()), parent, symbol, _initial_data);
} else {
std::list<Glib::ustring> uri_list = get_filenames();
@@ -194,7 +194,7 @@ LoadGraphWindow::ok_clicked()
symbol = avoid_symbol_clash(symbol);
_app->loader()->load_graph(
- false, u, _graph->path(), symbol, _initial_data);
+ false, FilePath(URI(u).path()), _graph->path(), symbol, _initial_data);
}
}
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index 891502f7..7a80fa6e 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -46,7 +46,9 @@ ThreadedLoader::~ThreadedLoader()
{
_exit_flag = true;
_sem.post();
- _thread.join();
+ if (_thread.joinable()) {
+ _thread.join();
+ }
}
SPtr<Parser>
@@ -59,23 +61,22 @@ void
ThreadedLoader::run()
{
while (_sem.wait() && !_exit_flag) {
- _mutex.lock();
+ std::lock_guard<std::mutex> lock(_mutex);
while (!_events.empty()) {
_events.front()();
_events.pop_front();
}
- _mutex.unlock();
}
}
void
ThreadedLoader::load_graph(bool merge,
- const Glib::ustring& document_uri,
+ const FilePath& file_path,
optional<Raul::Path> engine_parent,
optional<Raul::Symbol> engine_symbol,
optional<Properties> engine_data)
{
- _mutex.lock();
+ std::lock_guard<std::mutex> lock(_mutex);
Glib::ustring engine_base = "";
if (engine_parent) {
@@ -88,17 +89,16 @@ ThreadedLoader::load_graph(bool merge,
_events.push_back(sigc::hide_return(
sigc::bind(sigc::mem_fun(this, &ThreadedLoader::load_graph_event),
- document_uri,
+ file_path,
engine_parent,
engine_symbol,
engine_data)));
- _mutex.unlock();
_sem.post();
}
void
-ThreadedLoader::load_graph_event(const Glib::ustring& document_uri,
+ThreadedLoader::load_graph_event(const FilePath& file_path,
optional<Raul::Path> engine_parent,
optional<Raul::Symbol> engine_symbol,
optional<Properties> engine_data)
@@ -107,7 +107,7 @@ ThreadedLoader::load_graph_event(const Glib::ustring& document_uri,
_app.world()->parser()->parse_file(_app.world(),
_app.world()->interface().get(),
- document_uri,
+ file_path,
engine_parent,
engine_symbol,
engine_data);
@@ -116,14 +116,13 @@ ThreadedLoader::load_graph_event(const Glib::ustring& document_uri,
void
ThreadedLoader::save_graph(SPtr<const Client::GraphModel> model, const URI& uri)
{
- _mutex.lock();
+ std::lock_guard<std::mutex> lock(_mutex);
_events.push_back(sigc::hide_return(
sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event),
model,
uri)));
- _mutex.unlock();
_sem.post();
}
diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp
index 64968230..79ef6466 100644
--- a/src/gui/ThreadedLoader.hpp
+++ b/src/gui/ThreadedLoader.hpp
@@ -21,11 +21,12 @@
#include <cassert>
#include <list>
+#include <mutex>
#include <string>
#include <boost/optional.hpp>
-#include <glibmm/thread.h>
+#include "ingen/FilePath.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Parser.hpp"
#include "ingen/Serialiser.hpp"
@@ -57,7 +58,7 @@ public:
~ThreadedLoader();
void load_graph(bool merge,
- const Glib::ustring& document_uri,
+ const FilePath& file_path,
boost::optional<Raul::Path> engine_parent,
boost::optional<Raul::Symbol> engine_symbol,
boost::optional<Properties> engine_data);
@@ -67,7 +68,7 @@ public:
SPtr<Parser> parser();
private:
- void load_graph_event(const Glib::ustring& document_uri,
+ void load_graph_event(const FilePath& file_path,
boost::optional<Raul::Path> engine_parent,
boost::optional<Raul::Symbol> engine_symbol,
boost::optional<Properties> engine_data);
@@ -83,7 +84,7 @@ private:
App& _app;
Raul::Semaphore _sem;
SPtr<Interface> _engine;
- Glib::Mutex _mutex;
+ std::mutex _mutex;
std::list<Closure> _events;
bool _exit_flag;
std::thread _thread;