Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16.0)

project(JlQML)

set(JlQML_VERSION 0.10.3)
set(JlQML_VERSION 0.10.4)
message(STATUS "Project version: v${JlQML_VERSION}")

set(CMAKE_MACOSX_RPATH 1)
Expand Down
19 changes: 11 additions & 8 deletions julia_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,19 @@ void JuliaAPI::set_js_engine(QJSEngine* e)
m_engine = e;
if(m_engine != nullptr)
{
for(JuliaFunction* f : m_registered_functions)
for(JuliaFunction* f : registered_functions())
{
register_function_internal(f);
}
m_registered_functions.clear();
}
}

void JuliaAPI::register_function(const QString& name, jl_value_t* f)
{
JuliaFunction* jf = new JuliaFunction(name, f, this);
if(m_engine == nullptr)
{
m_registered_functions.push_back(jf);
}
else
JuliaFunction* jf = new JuliaFunction(name, f, QGuiApplication::instance());
registered_functions().push_back(jf);

if(m_engine != nullptr)
{
register_function_internal(jf);
}
Expand Down Expand Up @@ -64,6 +61,12 @@ void JuliaAPI::register_function_internal(JuliaFunction* jf)
(*this)[jf->name()] = f.toVariant(QJSValue::RetainJSObjects);
}

std::vector<JuliaFunction*>& JuliaAPI::registered_functions()
{
static std::vector<JuliaFunction*> functions;
return functions;
}

JuliaAPI* JuliaSingleton::create(QQmlEngine* qmlEngine, QJSEngine* scriptEngine)
{
Q_ASSERT(s_singletonInstance);
Expand Down
2 changes: 1 addition & 1 deletion julia_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class JuliaAPI : public QQmlPropertyMap
JuliaSignals* m_julia_signals = nullptr;
void register_function_internal(JuliaFunction* f);
QJSEngine* m_engine = nullptr;
std::vector<JuliaFunction*> m_registered_functions;
std::vector<JuliaFunction*>& registered_functions();
};

struct JuliaSingleton
Expand Down
5 changes: 5 additions & 0 deletions makie_viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ struct MakieSupport
MakieViewport::MakieViewport(QQuickItem *parent) : OpenGLViewport(parent, new MakieRenderFunction(m_screen, m_scene))
{
get_makie_support_module(); // Throw the possible error early
connect(this, &MakieViewport::sceneChanged, [this] ()
{
update();
});
}

MakieViewport::~MakieViewport()
Expand Down Expand Up @@ -124,6 +128,7 @@ void MakieViewport::setScene(qvariant_any_t scene)
jlcxx::unprotect_from_gc(m_scene);
}
m_scene = scene_val;
emit sceneChanged(scene);
}

void MakieViewport::setup_buffer(QOpenGLFramebufferObject* fbo)
Expand Down
2 changes: 1 addition & 1 deletion makie_viewport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MakieViewport : public OpenGLViewport
static jlcxx::SafeCFunction m_default_render_function;

signals:
void sceneChanged();
void sceneChanged(qvariant_any_t scene);

private:
// Screen created and used on the Julia side
Expand Down
Loading