• 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

39.24
/src/lib/score/graphics/GraphicsItem.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 "GraphicsItem.hpp"
4

5
#include <score/graphics/ItemBounder.hpp>
6
#include <score/widgets/ItemViewDrag.hpp>
7
#include <score/plugins/UuidKey.hpp>
8
#include <score/tools/Debug.hpp>
9
#include <ossia/detail/hash_map.hpp>
10

11
#include <QUrl>
12
#include <QGraphicsItem>
13
#include <QGraphicsScene>
14
#include <QGraphicsView>
15
#include <QGuiApplication>
16
#include <QInputMethod>
17

18
using item_help = ossia::hash_map<int, std::pair<QString, QUrl>>;
19
#if __has_include(<QApplicationStatic>)
20
#include <QApplicationStatic>
21
Q_APPLICATION_STATIC(item_help, g_itemHelpRegistry);
22
#else
23
Q_GLOBAL_STATIC(item_help, g_itemHelpRegistry);
29✔
24
#endif
25

26
void registerItemHelp(int itemType, QString tooltip, QUrl url) noexcept
319✔
27
{
28
  auto& val = *g_itemHelpRegistry;
319✔
29
  val[itemType] = std::pair<QString, QUrl>{tooltip, url};
319✔
30
}
319✔
31

32
QUrl getItemHelpUrl(int itemType) noexcept
×
33
{
34
  auto& val = *g_itemHelpRegistry;
×
35
  return val[itemType].second;
×
36
}
37

38

39
namespace score
40
{
41
#if !defined(__EMSCRIPTEN__)
42
// The WebAssembly implementations live in WasmInputMethod.cpp.
43
void retargetInputMethod(QObject* target) noexcept
×
44
{
45
  (void)target;
46
}
×
47

48
void watchSceneInputMethod(QGraphicsScene& scene)
12✔
49
{
50
  (void)scene;
12✔
51
}
12✔
52
#endif
53
}
54

55
void deleteGraphicsObject(QGraphicsObject* item)
×
56
{
57
  if(item)
×
58
  {
59
    auto sc = item->scene();
×
60

61
    if(sc)
×
62
    {
63
      sc->removeItem(item);
×
64
    }
×
65

66
    item->deleteLater();
×
67
  }
×
68
}
×
69

70
void deleteGraphicsItem(QGraphicsItem* item)
116✔
71
{
72
  if(item)
116✔
73
  {
74
    auto sc = item->scene();
116✔
75

76
    if(sc)
116✔
77
    {
78
      sc->removeItem(item);
116✔
79
    }
116✔
80

81
    delete item;
116✔
82
  }
116✔
83
}
116✔
84

85
QGraphicsView* getView(const QGraphicsItem& self)
4✔
86
{
87
  if(!self.scene())
4✔
88
    return nullptr;
×
89
  auto v = self.scene()->views();
4✔
90
  if(v.empty())
4✔
91
    return nullptr;
×
92
  return v.first();
4✔
93
}
4✔
94

95
// TODO apparently crashes on macOS... investigate
96
QGraphicsView* getView(const QPainter& painter)
×
97
{
98
  auto widg = static_cast<QWidget*>(painter.device());
×
99
  SCORE_ASSERT(widg);
×
100
  return static_cast<QGraphicsView*>(widg->parent());
×
101
}
102

103
QImage newImage(double logical_w, double logical_h)
27✔
104
{
105
  double ratio = qGuiApp->devicePixelRatio();
27✔
106
  QImage img(
54✔
107
      std::ceil(logical_w * ratio), logical_h * ratio,
27✔
108
      QImage::Format_ARGB32_Premultiplied);
109
  img.setDevicePixelRatio(ratio);
27✔
110
  img.fill(Qt::transparent);
27✔
111
  return img;
27✔
112
}
27✔
113

114
std::optional<QPointF> mapPointToItem(QPoint global, QGraphicsItem& item)
×
115
{
116
  // Get the QGraphicsView
117
  auto views = item.scene()->views();
×
118
  if(views.empty())
×
119
    return std::nullopt;
×
120

121
  auto view = views.front();
×
122

123
  // Find where to paste in the scenario
124
  auto view_pt = view->mapFromGlobal(global);
×
125
  auto scene_pt = view->mapToScene(view_pt);
×
126
  return item.mapFromScene(scene_pt);
×
127
}
×
128

129
namespace score
130
{
131
std::pair<double, bool>
132
ItemBounder::bound(QGraphicsItem* parent, double x0, double w) noexcept
×
133
{
134
  auto view = getView(*parent);
×
135
  int item_left = view->mapFromScene(parent->mapToScene({x0, 0.})).x();
×
136
  int item_right = item_left + w;
×
137

138
  double x = x0;
×
139
  const double min_x = x0;
×
140
  const double max_x = view->width() - 30.;
×
141

142
  if(item_left <= min_x)
×
143
  {
144
    // Compute the pixels needed to add to have top-left at 0
145
    x = x - item_left + min_x;
×
146
  }
×
147
  else if(item_right >= max_x)
×
148
  {
149
    // Compute the pixels needed to add to have top-right at max
150
    x = x - item_right + max_x;
×
151
  }
×
152
  x = std::max(x, 2 * x0);
×
153

154
  if(std::abs(m_x - x) > 0.1)
×
155
  {
156
    m_x = x;
×
157
    return {x, true};
×
158
  }
159
  else
160
  {
161
    return {x, false};
×
162
  }
163
}
×
164
}
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