# HG changeset patch # User Chris Cannam # Date 1588254433 -3600 # Node ID ae2d5f8ff00528b8d734e040b309cc437ea12052 # Parent 5feb1a8318dfa9d449b6da8f5bdb3886efe3ad98 When asked to render the whole view width, we need to wait for the layers to be ready before we can determine what the width is diff -r 5feb1a8318df -r ae2d5f8ff005 view/View.cpp --- a/view/View.cpp Wed Apr 29 17:47:55 2020 +0100 +++ b/view/View.cpp Thu Apr 30 14:47:13 2020 +0100 @@ -2992,19 +2992,12 @@ } bool -View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) +View::waitForLayersToBeReady() { - int x0 = int(round(m_zoomLevel.framesToPixels(double(f0)))); - int x1 = int(round(m_zoomLevel.framesToPixels(double(f1)))); - - int w = x1 - x0; - - sv_frame_t origCentreFrame = m_centreFrame; - bool someLayersIncomplete = false; #ifdef DEBUG_VIEW - SVDEBUG << "View::render: checking completion" << endl; + SVDEBUG << "View::waitForLayersToBeReady: checking completion" << endl; #endif for (LayerList::iterator i = m_layerStack.begin(); @@ -3064,8 +3057,31 @@ } #ifdef DEBUG_VIEW - SVDEBUG << "View::render: ok, we're ready" << endl; + SVDEBUG << "View::waitForLayersToBeReady: ok, we're ready" << endl; #endif + + return true; +} + +bool +View::render(QPainter &paint, int xorigin, sv_frame_t f0, sv_frame_t f1) +{ + int x0 = int(round(m_zoomLevel.framesToPixels(double(f0)))); + int x1 = int(round(m_zoomLevel.framesToPixels(double(f1)))); + + int w = x1 - x0; + +#ifdef DEBUG_VIEW + SVDEBUG << "View::render: Render request is for frames " << f0 + << " to " << f1 << " (pixels " << x0 << " to " << x1 + << ", width " << w << ")" << endl; +#endif + + if (!waitForLayersToBeReady()) { + return false; + } + + sv_frame_t origCentreFrame = m_centreFrame; QProgressDialog progress(tr("Rendering image..."), tr("Cancel"), 0, w / width(), this); @@ -3123,6 +3139,10 @@ QImage * View::renderToNewImage() { + if (!waitForLayersToBeReady()) { + return nullptr; + } + sv_frame_t f0 = getModelsStartFrame(); sv_frame_t f1 = getModelsEndFrame(); diff -r 5feb1a8318df -r ae2d5f8ff005 view/View.h --- a/view/View.h Wed Apr 29 17:47:55 2020 +0100 +++ b/view/View.h Thu Apr 30 14:47:13 2020 +0100 @@ -530,6 +530,8 @@ void checkProgress(ModelId); void checkAlignmentProgress(ModelId); + + bool waitForLayersToBeReady(); // returns false if user cancelled waiting int getProgressBarWidth() const; // if visible