• 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

18.48
/src/lib/core/application/SafeQApplication.cpp
1
// This is an open source non-commercial project. Dear PVS-Studio, please check
2
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
3
#include "SafeQApplication.hpp"
4

5
#include <score/graphics/GraphicsItem.hpp>
6
#include <score/tools/Debug.hpp>
7
#include <score/tools/std/Invoke.hpp>
8

9
#include <QDebug>
10
#include <QDesktopServices>
11
#include <QFileInfo>
12
#include <QFileOpenEvent>
13
#include <QGraphicsView>
14
#include <QGraphicsItem>
15
#include <QTimer>
16
#include <QThread>
17

18
#include <wobjectimpl.h>
19

20
#if defined(__EMSCRIPTEN__)
21
#include <core/application/WasmLogging.hpp>
22
#endif
23

24
W_OBJECT_IMPL(SafeQApplication)
×
25

26
SafeQApplication::~SafeQApplication() { }
×
27

28
#if defined(__EMSCRIPTEN__)
29
bool SafeQApplication::lastMessageWasSuppressed() noexcept
30
{
31
  return score::wasm::lastMessageWasSuppressed();
32
}
33
#else
34
bool SafeQApplication::lastMessageWasSuppressed() noexcept
43✔
35
{
36
  return false;
43✔
37
}
38
#endif
39

40
void SafeQApplication::DebugOutput(
43✔
41
    QtMsgType type, const QMessageLogContext& context, const QString& msg)
42
{
43
#if defined(__EMSCRIPTEN__)
44
  score::wasm::logMessage(type, context, msg);
45
  if(type == QtFatalMsg)
46
  {
47
    SCORE_BREAKPOINT;
48
    std::terminate();
49
  }
50
  return;
51
#else
52
  auto basename_arr = QFileInfo(context.file).baseName().toUtf8();
43✔
53
  auto basename = basename_arr.constData();
43✔
54
  FILE* out_file = stderr;
43✔
55
#if defined(_MSC_VER)
56
  static LogFile logger;
57
  out_file = logger.desc();
58
#endif
59

60
  QByteArray localMsg = msg.toLocal8Bit();
43✔
61
  switch(type)
43✔
62
  {
63
    case QtDebugMsg:
64
      fprintf(
39✔
65
          out_file, "Debug: %s (%s:%u)\n", localMsg.constData(), basename, context.line);
39✔
66
      break;
39✔
67
    case QtInfoMsg:
68
      fprintf(
×
69
          out_file, "Info: %s (%s:%u)\n", localMsg.constData(), basename, context.line);
×
70
      break;
×
71
    case QtWarningMsg:
72
      fprintf(
4✔
73
          out_file, "Warning: %s (%s:%u)\n", localMsg.constData(), basename,
4✔
74
          context.line);
4✔
75
      break;
4✔
76
    case QtCriticalMsg:
77
      fprintf(
×
78
          out_file, "Critical: %s (%s:%u)\n", localMsg.constData(), basename,
×
79
          context.line);
×
80
      break;
×
81
    case QtFatalMsg:
82
      fprintf(
×
83
          out_file, "Fatal: %s (%s:%u)\n", localMsg.constData(), basename, context.line);
×
84
      SCORE_BREAKPOINT;
×
85
      std::terminate();
×
86
  }
87
  fflush(out_file);
43✔
88
#endif
89
}
43✔
90

91
Q_GLOBAL_STATIC(QUrl, g_next_help_url_to_open);
×
92
Q_GLOBAL_STATIC(QTimer, g_next_help_url_to_open_timer);
×
93
static void open_help_url(const QUrl& u)
×
94
{
95
  if(g_next_help_url_to_open.isDestroyed())
×
96
    return;
×
97

98
  *g_next_help_url_to_open = u;
×
99
  g_next_help_url_to_open_timer->stop();
×
100
  g_next_help_url_to_open_timer->setSingleShot(true);
×
101
  QObject::disconnect(&*g_next_help_url_to_open_timer, &QTimer::timeout, qApp, nullptr);
×
102
  QObject::connect(&*g_next_help_url_to_open_timer, &QTimer::timeout, qApp, [] {
×
103
    QDesktopServices::openUrl(*g_next_help_url_to_open);
×
104
  });
×
105

106
  g_next_help_url_to_open_timer->start(15);
×
107
}
×
108

109
static void open_help_url(QGraphicsItem* item)
×
110
{
111
  if(!item)
×
112
    return;
×
113

114
  if(auto url = getItemHelpUrl(item->type()); !url.isEmpty())
×
115
  {
116
    open_help_url(url);
×
117
  }
×
118
  else if(auto data = item->data(0xF1); data.isValid())
×
119
  {
120
    open_help_url(data.toUrl());
×
121
  }
×
122
  else
123
  {
124
    open_help_url(item->parentItem());
×
125
  }
126
}
×
127

128
static void process_help_event(QObject* receiver, QEvent* event)
×
129
{
130
  if(auto res = receiver->property("help_url"); res.isValid())
×
131
  {
132
    auto url = res.value<QUrl>();
×
133
    open_help_url(url);
×
134
  }
×
135
  else if(auto gv = qobject_cast<QGraphicsView*>(receiver))
×
136
  {
137
    auto pos = QCursor::pos();
×
138
    auto pt = gv->viewport()->mapFromGlobal(pos);
×
139
    open_help_url(gv->itemAt(pt));
×
140
  }
×
141
  else if(auto gs = qobject_cast<QGraphicsScene*>(receiver))
×
142
  {
143
    auto pos = QCursor::pos();
×
144
    auto gvs = gs->views();
×
145
    if(!gvs.empty())
×
146
    {
147
      auto gv = gvs[0];
×
148
      auto pt = gv->mapFromGlobal(pos);
×
149
      open_help_url(gv->itemAt(pt));
×
150
    }
×
151
  }
×
152
  else
153
  {
154
    open_help_url(QUrl("https://ossia.io/score-docs"));
×
155
  }
156
}
×
157

158
bool SafeQApplication::notify(QObject* receiver, QEvent* event)
×
159
{
160
#if !defined(SCORE_DEBUG)
161
  try
162
  {
163
#endif
164
    if(event->type() == QEvent::KeyPress)
×
165
    {
166
      auto ev = (QKeyEvent*)(event);
×
167
      if(ev->key() == Qt::Key_F1)
×
168
        process_help_event(receiver, event);
×
169
    }
×
170
    return QApplication::notify(receiver, event);
×
171
#if !defined(SCORE_DEBUG)
172
  }
173
  catch(std::exception& e)
174
  {
175
    thread_local bool reentr = false;
176
    if(this->thread() != QThread::currentThread() || reentr)
177
    {
178
      qDebug() << "Internal error: " << e.what();
179
    }
180
    else
181
    {
182
      reentr = true;
183
      inform(QObject::tr("Internal error: ") + e.what());
184
      reentr = false;
185
    }
186
  }
187
  catch(...)
188
  {
189
    thread_local bool reentr = false;
190
    if(this->thread() != QThread::currentThread() || reentr)
191
    {
192
      qDebug() << "Internal error: ";
193
    }
194
    else
195
    {
196
      reentr = true;
197
      inform(QObject::tr("Internal error: "));
198
      reentr = false;
199
    }
200
  }
201

202
  return false;
203
#endif
204
}
205

206
bool SafeQApplication::event(QEvent* ev)
×
207
{
208
  switch((int)ev->type())
×
209
  {
210
    case QEvent::FileOpen: {
211
      auto loadString = static_cast<QFileOpenEvent*>(ev)->file();
×
212
#if defined(__APPLE__)
213
      // Used for the case when the user double-clicks something
214
      // with score not yet open, thus it's too early when the event
215
      // is processed
216
      this->fileToOpen = loadString;
217
#endif
218
      fileOpened(loadString);
×
219
      return true;
×
220
    }
×
221
    case QEvent::HelpRequest:
222
      return QApplication::event(ev);
×
223
    default:
224
      return QApplication::event(ev);
×
225
  }
226
}
×
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