summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-01-21 00:41:34 +0100
committerDavid Robillard <d@drobilla.net>2018-01-21 00:56:50 +0100
commita99b72e4adbc4c28fadc08d29299d99405f72db9 (patch)
treefb21f2cea8f5db1dc187cdbdd01f43e73bbddfff /src/gui
parent329f498d901f9be9c0c820749850f5277a17df5d (diff)
downloadingen-a99b72e4adbc4c28fadc08d29299d99405f72db9.tar.gz
ingen-a99b72e4adbc4c28fadc08d29299d99405f72db9.tar.bz2
ingen-a99b72e4adbc4c28fadc08d29299d99405f72db9.zip
Add FilePath class and remove use of glib path utilities
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;