• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ossia / score / 30213925900

26 Jul 2026 06:03PM UTC coverage: 15.298% (-0.01%) from 15.311%
30213925900

push

github

jcelerier
3rdparty: bump libossia for the network-context poll fix

Brings in ossia/libossia#913: SDL joystick init no longer requires haptic
support (which the Emscripten SDL2 port does not have), and
network_context::poll() restarts the io_context, without which the
WebAssembly polling path stops after its first tick.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019oPj1zRcxSQX7FNni7EHM6

30400 of 198713 relevant lines covered (15.3%)

997.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.59
/src/plugins/score-plugin-js/JS/ApplicationPlugin.cpp
1
#include "ApplicationPlugin.hpp"
2

3
#include <JS/DocumentPlugin.hpp>
4
#include <JS/Qml/DeviceContext.hpp>
5
#include <JS/Qml/EditContext.hpp>
6
#include <JS/Qml/Utils.hpp>
7
#include <JS/Qml/ViewContext.hpp>
8
#include <Library/LibrarySettings.hpp>
9
#include <LocalTree/LocalTreeDocumentPlugin.hpp>
10

11
#include <core/application/ApplicationInterface.hpp>
12
#include <core/document/Document.hpp>
13
#include <core/presenter/DocumentManager.hpp>
14

15
#include <ossia/detail/thread.hpp>
16

17
#include <ossia-qt/invoke.hpp>
18
#include <ossia-qt/qml_protocols.hpp>
19

20
#include <QCommandLineParser>
21

22
#if __has_include(<QQuickWindow>)
23
#include <QGuiApplication>
24
#include <QQuickItem>
25
#include <QQuickWindow>
26
#endif
27

28
#if SCORE_HAS_GPU_JS
29
#include <Gfx/Settings/Model.hpp>
30
#endif
31

32
#include <ossia/network/context.hpp>
33

34
namespace JS
35
{
36
ApplicationPlugin::ApplicationPlugin(const score::GUIApplicationContext& ctx)
36✔
37
    : score::GUIApplicationPlugin{ctx}
36✔
38
{
36✔
39
  // For the console
40
  m_consoleEngine.globalObject().setProperty("Score", m_consoleEngine.newQObject(new EditJsContext));
36✔
41
  m_consoleEngine.globalObject().setProperty("Util", m_consoleEngine.newQObject(new JsUtils));
36✔
42
  m_consoleEngine.globalObject().setProperty(
72✔
43
      "System", m_consoleEngine.newQObject(new JsSystem));
36✔
44
  m_consoleEngine.globalObject().setProperty(
72✔
45
      "Library", m_consoleEngine.newQObject(new JsLibrary));
36✔
46
  m_consoleEngine.globalObject().setProperty("Device", m_consoleEngine.newQObject(new DeviceContext{m_consoleEngine}));
36✔
47
  m_consoleEngine.globalObject().setProperty("View", m_consoleEngine.newQObject(new JsViewContext));
36✔
48
  connect(&m_consoleEngine, &QQmlEngine::exit, this, [&] {
36✔
49
    for(auto& doc : score::GUIAppContext().docManager.documents())
×
50
      doc->commandStack().markCurrentIndexAsSaved();
×
51
    qApp->quit();
×
52
    QTimer::singleShot(
×
53
        500, [] { score::GUIApplicationInterface::instance().forceExit(); });
×
54
  });
×
55
  m_asioContext = std::make_shared<ossia::net::network_context>();
36✔
56
  m_processMessages = true;
36✔
57
  m_consoleEngine.globalObject().setProperty(
72✔
58
      "Protocols",
36✔
59
      m_consoleEngine.newQObject(new ossia::qt::qml_protocols{m_asioContext, this}));
36✔
60
  m_asioThread = std::thread{[this] {
72✔
61
    ossia::set_thread_name("ossia app asio");
36✔
62
    while(m_processMessages)
72✔
63
    {
64
      m_asioContext->run();
36✔
65
    }
66
  }};
36✔
67

68
  // For scripts of processes that run in the ui thread:
69
  m_scriptProcessUIEngine.globalObject().setProperty(
72✔
70
      "Util", m_scriptProcessUIEngine.newQObject(new JsUtils));
36✔
71
  m_scriptProcessUIEngine.globalObject().setProperty(
72✔
72
      "System", m_scriptProcessUIEngine.newQObject(new JsSystem));
36✔
73
  m_scriptProcessUIEngine.globalObject().setProperty(
72✔
74
      "Library", m_scriptProcessUIEngine.newQObject(new JsLibrary));
36✔
75
  m_scriptProcessUIEngine.globalObject().setProperty(
72✔
76
      "View", m_scriptProcessUIEngine.newQObject(new JsViewContext));
36✔
77

78
  // Command-line option parsing
79
  QCommandLineParser parser;
36✔
80

81
  QCommandLineOption script_opt(
36✔
82
      "script", QCoreApplication::translate("js", "script"), "Script", "");
36✔
83
  parser.addOption(script_opt);
36✔
84

85
  parser.parse(ctx.applicationSettings.arguments);
36✔
86
  this->m_start_script = parser.value(script_opt);
36✔
87
}
×
88

89
void ApplicationPlugin::on_newDocument(score::Document& doc)
18✔
90
{
91
  score::addDocumentPlugin<DocumentPlugin>(doc);
18✔
92
}
18✔
93

94
ApplicationPlugin::~ApplicationPlugin()
72✔
95
{
36✔
96
  m_processMessages = false;
36✔
97
  m_asioContext->context.stop();
36✔
98
  m_asioThread.join();
36✔
99
}
72✔
100

101
void ApplicationPlugin::on_createdDocument(score::Document& doc)
20✔
102
{
103
  // Local Tree
104
  LocalTree::DocumentPlugin* lt = doc.context().findPlugin<LocalTree::DocumentPlugin>();
20✔
105
  if(lt)
20✔
106
  {
107
    auto& root = lt->device().get_root_node();
20✔
108

109
    auto node = root.create_child("script");
20✔
110
    auto address = node->create_parameter(ossia::val_type::STRING);
20✔
111
    address->set_value(std::string{});
20✔
112
    address->set_access(ossia::access_mode::SET);
20✔
113
    address->add_callback([&](const ossia::value& v) {
20✔
114
      ossia::qt::run_async(
×
115
          this, [this, str = QString::fromStdString(ossia::convert<std::string>(v))] {
×
116
        auto res = m_consoleEngine.evaluate(str);
×
117
        if(res.isError())
×
118
        {
119
          qDebug() << res.toString();
×
120
        }
×
121
      });
×
122
    });
×
123
  }
20✔
124

125
  // Custom data
126
  if(auto customData = doc.context().findPlugin<DocumentPlugin>(); !customData)
20✔
127
    score::addDocumentPlugin<DocumentPlugin>(doc);
×
128

129
  if(!m_start_script.isEmpty())
20✔
130
  {
131
    QTimer::singleShot(100, this, [this] { m_consoleEngine.evaluate(m_start_script); });
×
132
  }
×
133
}
20✔
134
void ApplicationPlugin::afterStartup()
×
135
{
136
  // Dummy engine setup for JS processes
137
  // eng.importModule(
138
  //     "/home/jcelerier/Documents/ossia/score/packages/default/Scripts/include/"
139
  //     "tonal.mjs");
140
  for(auto& p : this->context.settings<Library::Settings::Model>().getIncludePaths())
×
141
  {
142
    m_scriptProcessUIEngine.addImportPath(p);
×
143
  }
144

145
#if __has_include(<QQuickWindow>)
146
  if(QFileInfo f{context.applicationSettings.ui}; f.isFile())
×
147
  {
148
    m_comp = new QQmlComponent{&m_consoleEngine, f.absoluteFilePath(), this};
×
149

150
    if(auto obj = m_comp->create())
×
151
    {
152
      if(auto item = qobject_cast<QQuickItem*>(obj))
×
153
      {
154
        m_window = new QQuickWindow{};
×
155
  // QWidget gets these from QWidgetPrivate::adjustFlags; a bare QQuickWindow
156
  // does not, and on platforms where Qt draws the chrome itself (wasm) that
157
  // leaves the window with no title bar, close or minimise button.
158
  m_window->setFlags(
×
159
      m_window->flags() | Qt::Window | Qt::WindowTitleHint | Qt::WindowSystemMenuHint
×
160
      | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint
×
161
      | Qt::WindowMaximizeButtonHint);
×
162
#if defined(__EMSCRIPTEN__)
163
  // Qt for wasm reports ShowIsFullScreen unconditionally, so QWindow::show()
164
  // turns into showFullScreen() for every top level: the requested size is
165
  // discarded and the full-screen state suppresses the frame. Only Qt::Dialog
166
  // and Qt::Popup opt out (QWasmIntegration::defaultWindowState).
167
  m_window->setFlags(m_window->flags() | Qt::Dialog);
168
#endif
169
        m_window->setWidth(640);
×
170
        m_window->setHeight(480);
×
171
        item->setParentItem(m_window->contentItem());
×
172
#if defined(__EMSCRIPTEN__)
173
        m_window->showNormal();
174
#else
175
        m_window->show();
×
176
#endif
177
        return;
×
178
      }
179
    }
×
180
    else
181
    {
182
      qDebug() << m_comp->errorString();
×
183
      qGuiApp->exit(1);
×
184
    }
185
    delete m_comp;
×
186
  }
×
187
#endif
188
}
×
189
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc