[elvystrac] r1740 - elvys should not freeze any more when quiting

  • From: elvys@xxxxxxxxxxxxxxxxxxxxxx
  • To: elvystrac@xxxxxxxxxxxxx
  • Date: Tue, 16 Feb 2010 10:21:08 +0100

Author: JirkaH
Date: 2010-02-16 10:21:07 +0100 (Tue, 16 Feb 2010)
New Revision: 1740

Modified:
   branches/client/pdf-presentation-branch/elvys-client/src/Makefile
   branches/client/pdf-presentation-branch/elvys-client/src/main.cpp
   branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp
   
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp
   
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.h
   
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp
   
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h
Log:
elvys should not freeze any more when quiting


Modified: branches/client/pdf-presentation-branch/elvys-client/src/Makefile
===================================================================
--- branches/client/pdf-presentation-branch/elvys-client/src/Makefile   
2010-02-15 22:28:45 UTC (rev 1739)
+++ branches/client/pdf-presentation-branch/elvys-client/src/Makefile   
2010-02-16 09:21:07 UTC (rev 1740)
@@ -1,6 +1,6 @@
 #############################################################################
 # Makefile for building: ../bin/elvys-client
-# Generated by qmake (2.01a) (Qt 4.5.3) on: Sun Feb 14 20:14:17 2010
+# Generated by qmake (2.01a) (Qt 4.5.3) on: Tue Feb 16 09:19:19 2010
 # Project:  src.pro
 # Template: app
 # Command: /usr/bin/qmake -spec /usr/share/qt4/mkspecs/linux-g++ -unix 
CONFIG+=debug_and_release -o Makefile src.pro

Modified: branches/client/pdf-presentation-branch/elvys-client/src/main.cpp
===================================================================
--- branches/client/pdf-presentation-branch/elvys-client/src/main.cpp   
2010-02-15 22:28:45 UTC (rev 1739)
+++ branches/client/pdf-presentation-branch/elvys-client/src/main.cpp   
2010-02-16 09:21:07 UTC (rev 1740)
@@ -76,7 +76,7 @@
 //     Saver * saver = new Saver();
 //     saver->setWidget(&elvys);
 
-//     elvys.showFullScreen();
+       //elvys.showFullScreen();
        elvys.setGeometry(0,0,400,300);
        elvys.show();
 

Modified: branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp
===================================================================
--- branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp      
2010-02-15 22:28:45 UTC (rev 1739)
+++ branches/client/pdf-presentation-branch/elvys-client/src/pdffiller.cpp      
2010-02-16 09:21:07 UTC (rev 1740)
@@ -41,6 +41,7 @@
  * Class desctructor. Waits for all threads to die.
  */
 PDFFiller::~PDFFiller() {
+       qWarning() << "pdffiller deleted" << filename;
        quit = true;
        condition.wakeAll();
        wait();
@@ -51,8 +52,7 @@
        if (pageNormal) {
                delete pageNormal;
        }
-       cache.clear();
-       //qDebug() << "pdffiller deleted";
+       cache.clear();  
 }
 
 
@@ -456,26 +456,27 @@
                return false;
        }
 
-       //silly waiting for pdf to get ready
-       while (restart ||  pdf == NULL ) { //wait for initialization
-               if ( ! ready ) {
+       //silly waiting for pdf to get ready    
+       mutexPDF.lock();
+       mutexCond.lock();
+       if (restart ||  pdf == NULL ) { //wait for initialization
+               mutexCond.unlock();
+               mutexPDF.unlock();
                mutexPages->unlock();
-                       return false;
-               }
+               return false;
        }
+       mutexCond.unlock();
 
-       mutexPDF.lock();
        numPages = pdfGetNumPages(pdf);
-       mutexPDF.unlock();
+       mutexPDF.unlock();      
+       // new page numbers
 
-       // new page numbers4
-
        pages.clear();
        for (int i = 0; i < _pages.size(); ++i) {
                if ( _pages[i] <= numPages ) {
                        pages.insert(i, _pages[i]);
                } else {
-                       qWarning() << "Trying to set up page no." << _pages[i] 
<< ", but document " << filename << "doesn't contain";
+                       qWarning() << "Trying to set up page no." << _pages[i] 
<< ", but document " << filename << "doesn't contain it";
                }
        }
        if ( _mainPage  <= numPages ) {
@@ -565,8 +566,7 @@
  * Closes current document and clears cache.
  */
 
-void PDFFiller::close() {
-       ready = false;
+void PDFFiller::close() {      
 
        mutexCond.lock(); //while it is rendering
 
@@ -592,10 +592,12 @@
        cache.clear();
        pages.clear();
        mutexPages->unlock();
+       mutexPDF.lock();
        if ( pdf ) {
                pdfFree(pdf);
        }
        pdf = NULL;
+       mutexPDF.unlock();
 }
 
 /**

Modified: 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp
===================================================================
--- 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp
        2010-02-15 22:28:45 UTC (rev 1739)
+++ 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.cpp
        2010-02-16 09:21:07 UTC (rev 1740)
@@ -172,7 +172,17 @@
        pdfPresViewer->setGeometry(geometry());
 }
 
+void PDFPresentationDocument::showEvent(QShowEvent * event) {
+       Q_UNUSED(event);
+
+       pdfPresViewer->setAcceptingPages(true);
+}
+
+
 void PDFPresentationDocument::hideEvent(QHideEvent * event) {  
+       Q_UNUSED(event);
+
+       pdfPresViewer->setAcceptingPages(false);
        pdfPresViewer->setAutoRotating(false);
        pdfFiller->clearCache();        
 }

Modified: 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.h
===================================================================
--- 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.h
  2010-02-15 22:28:45 UTC (rev 1739)
+++ 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationdocument.h
  2010-02-16 09:21:07 UTC (rev 1740)
@@ -43,6 +43,7 @@
        protected:
                virtual void resizeEvent(QResizeEvent * event);
                virtual void hideEvent(QHideEvent *event);
+               virtual void showEvent(QShowEvent * event);
 
        private:
                PDFPresentationViewer * pdfPresViewer;

Modified: 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp
===================================================================
--- 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp
  2010-02-15 22:28:45 UTC (rev 1739)
+++ 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.cpp
  2010-02-16 09:21:07 UTC (rev 1740)
@@ -22,7 +22,7 @@
 
 
 PDFPresentationViewer::PDFPresentationViewer(QWidget * parent, const QRect & 
rect) : QLabel (parent) {
-       closed = false;
+       _acceptingPages = true;
        origSize = rect;
        currentPage = 0;
        _period = 10;
@@ -61,7 +61,9 @@
 }
 
 PDFPresentationViewer::~PDFPresentationViewer() {
-       closed = true;
+       _acceptingPages = false;
+       qWarning() << "pdfpresviewer closed";
+
        if (nextTimer.isActive()) {
                nextTimer.stop();
        }
@@ -222,7 +224,7 @@
        QPixmap myPixmap;
        QString key;
 
-       if (closed) {
+       if ( ! _acceptingPages) {
                return;
        }
 
@@ -266,6 +268,14 @@
        manageMovements();
 }
 
+void PDFPresentationViewer::setAcceptingPages(bool accept) {
+       _acceptingPages = accept;
+}
+
+bool PDFPresentationViewer::acceptingPages() {
+       return _acceptingPages;
+}
+
 /** This is to provide maximum width and height of the pages in the document 
(not necessarily the same page) in normal mode.
 It sets geometry of the widget.
   @param width maximum width of page in the document
@@ -682,7 +692,7 @@
 }
 
 void PDFPresentationViewer::close() {
-       closed = true;
+       _acceptingPages = false;
        zoomable = false;
        setPixmap(NULL);
        setFocusPolicy(Qt::NoFocus);
@@ -694,7 +704,7 @@
        Q_UNUSED(filename);
 
        zoomable = true;
-       closed = false;
+       _acceptingPages = true;
 
        setFocusPolicy(Qt::StrongFocus);
        if ( QApplication::focusWidget() == NULL ) {

Modified: 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h
===================================================================
--- 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h
    2010-02-15 22:28:45 UTC (rev 1739)
+++ 
branches/client/pdf-presentation-branch/elvys-client/src/pdfpresentationviewer.h
    2010-02-16 09:21:07 UTC (rev 1740)
@@ -61,6 +61,8 @@
                int period();
                void setAutoRotating(bool enabled);
                void setPages(QList <int> & _pageNumbers);
+               void setAcceptingPages(bool accept);
+               bool acceptingPages();
 
 
        protected:
@@ -100,8 +102,8 @@
 
                int currentPage;
                int _period;
-               bool inPageTransition;
-               bool closed;
+               bool _acceptingPages;
+               bool inPageTransition;          
                ElvysNs::Position pageMovement;
                QList<ElvysNs::Position> pageChanges;
 


Other related posts:

  • » [elvystrac] r1740 - elvys should not freeze any more when quiting - elvys