Skip to content
Extraits de code Groupes Projets
Valider f1edf7d8 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Prevent crashes due to badly initialized of current Document

currentVivyDocument and currentScriptDocument macros don't always return
the "parent" document. This assumption lead to some badly initialized
data that considered the wrong document to be the "parent" of the view.

Fix the bad usage of those macros
parent 43a969d7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!29Improve timingView with display of the ASS lines
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using namespace Vivy::Ass; using namespace Vivy::Ass;
Line::Line() Line::Line()
// FIXME SEVERE: use of currentVivyDocument?
: assFactory(currentVivyDocument->getAssSubDocument()->getFactory()) : assFactory(currentVivyDocument->getAssSubDocument()->getFactory())
{ {
} }
......
...@@ -81,18 +81,25 @@ TimingScene::rebuildScene() ...@@ -81,18 +81,25 @@ TimingScene::rebuildScene()
addItem(cursor); addItem(cursor);
cursor->setPos(0, TimingUtils::axisHeight()); cursor->setPos(0, TimingUtils::axisHeight());
if (auto assDocument = currentVivyDocument->getAssSubDocument()) { // FIXME: bruh
QVector<Ass::LinePtr> lines = assDocument->getLines(); if (auto p = rootView.lock()) {
for (int i = 0; i < lines.size(); ++i) { if (auto v = p.get()) {
if (auto line = lines.at(i).get()) { if (auto d = v->getDocument()) {
TimingLine *l = new TimingLine(line, i); if (auto assDocument = d->getAssSubDocument()) {
l->setVisible(false); QVector<Ass::LinePtr> lines = assDocument->getLines();
addItem(l); for (int i = 0; i < lines.size(); ++i) {
timingLines.append(l); if (auto line = lines.at(i).get()) {
if (auto p = rootView.lock()) { TimingLine *l = new TimingLine(line, i);
if (auto assLinesModel = p->getAssLinesModel()) { l->setVisible(false);
connect(l, &TimingLine::lineChanged, assLinesModel, addItem(l);
&AssLinesModel::updateLine); timingLines.append(l);
if (auto p = rootView.lock()) {
if (auto assLinesModel = p->getAssLinesModel()) {
connect(l, &TimingLine::lineChanged, assLinesModel,
&AssLinesModel::updateLine);
}
}
}
} }
} }
} }
......
...@@ -16,6 +16,12 @@ ...@@ -16,6 +16,12 @@
#define VIVY_APP_LOGGABLE_OBJECT_BY_STORED_NAME(name, logger) \ #define VIVY_APP_LOGGABLE_OBJECT_BY_STORED_NAME(name, logger) \
VIVY_LOGGABLE_OBJECT_BY_STORED_NAME(vivyApp->getLogSink(), name, logger) VIVY_LOGGABLE_OBJECT_BY_STORED_NAME(vivyApp->getLogSink(), name, logger)
/*
* Be careful when using those two macros
* What you get here is the document currently selected as the current tab
* Fore exemple, there is no guarantee that this is the same document that
* the parent of a subDocument View you're calling those macros from
*/
#define currentVivyDocument dynamic_cast<VivyDocument *>(vivyApp->getCurrentDocument()) #define currentVivyDocument dynamic_cast<VivyDocument *>(vivyApp->getCurrentDocument())
#define currentScriptDocument dynamic_cast<ScriptDocument *>(vivyApp->getCurrentDocument()) #define currentScriptDocument dynamic_cast<ScriptDocument *>(vivyApp->getCurrentDocument())
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter