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,7 +81,11 @@ TimingScene::rebuildScene() ...@@ -81,7 +81,11 @@ TimingScene::rebuildScene()
addItem(cursor); addItem(cursor);
cursor->setPos(0, TimingUtils::axisHeight()); cursor->setPos(0, TimingUtils::axisHeight());
if (auto assDocument = currentVivyDocument->getAssSubDocument()) { // FIXME: bruh
if (auto p = rootView.lock()) {
if (auto v = p.get()) {
if (auto d = v->getDocument()) {
if (auto assDocument = d->getAssSubDocument()) {
QVector<Ass::LinePtr> lines = assDocument->getLines(); QVector<Ass::LinePtr> lines = assDocument->getLines();
for (int i = 0; i < lines.size(); ++i) { for (int i = 0; i < lines.size(); ++i) {
if (auto line = lines.at(i).get()) { if (auto line = lines.at(i).get()) {
...@@ -98,6 +102,9 @@ TimingScene::rebuildScene() ...@@ -98,6 +102,9 @@ TimingScene::rebuildScene()
} }
} }
} }
}
}
}
// FIXME: do we need to "disconnect" it when assLinesView or *this is destroyed, // FIXME: do we need to "disconnect" it when assLinesView or *this is destroyed,
// or is this taken care of by Qt alone? // or is this taken care of by Qt alone?
......
...@@ -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.
Veuillez vous inscrire ou vous pour commenter