From 6efc31682cf42ddbb5164886fc5940762d6793ce Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sun, 9 Jun 2019 14:41:54 +0300 Subject: [PATCH] Reader: eliminate duplicate calls to GoToFlow::preload() GoToFlow::setNumSlides() is called each time a comic is opened. So when e.g. three comics were opened one after another without restarting YACReader, each of the PictureFlow::centerIndexChanged* signals was connected to GoToFlow::preload three times, which multiplied the number of calls to preload() accordingly. During my testing PictureFlow::centerIndexChanged* signals were never emitted before the first call to GoToFlow::setNumSlides(), so connecting in GoToFlow::GoToFlow() should not cause extra calls to preload(). --- YACReader/goto_flow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index 110a4aa1..01a63aa8 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -40,6 +40,8 @@ GoToFlow::GoToFlow(QWidget *parent, FlowType flowType) flow->setSlideSize(imageSize); connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(setPageNumber(int))); connect(flow, SIGNAL(selected(unsigned int)), this, SIGNAL(goToPage(unsigned int))); + connect(flow, &PictureFlow::centerIndexChanged, this, &GoToFlow::preload); + connect(flow, &PictureFlow::centerIndexChangedSilent, this, &GoToFlow::preload); connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int))); connect(toolBar, SIGNAL(setCenter(unsigned int)), flow, SLOT(showSlide(unsigned int))); @@ -114,9 +116,6 @@ void GoToFlow::setNumSlides(unsigned int slides) numImagesLoaded = 0; - connect(flow, SIGNAL(centerIndexChanged(int)), this, SLOT(preload())); - connect(flow, SIGNAL(centerIndexChangedSilent(int)), this, SLOT(preload())); - ready = true; worker->reset();