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().
This commit is contained in:
Igor Kushnir 2019-06-09 14:41:54 +03:00 committed by Luis Ángel San Martín
parent 28b8fca729
commit 6efc31682c

View File

@ -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();