[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/graphics/oKular/kpdf [BROKEN EMAIL]
From:       Piotr Szymanski <djurban () pld-dc ! org>
Date:       2006-02-15 21:02:17
Message-ID: 1140037337.742864.7217.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 509917 by djurban:

- add minor checks for validity of requests
- fix ghostscript backend (works now)


 M  +2 -2      core/document.cpp  
 M  +2 -0      core/observer.h  
 M  +31 -18    generators/ghostview/generator_ghostview.cpp  
 M  +1 -1      generators/ghostview/interpreter_cmd.cpp  


--- trunk/playground/graphics/oKular/kpdf/core/document.cpp #509916:509917
@@ -1267,8 +1267,8 @@
     while ( !d->pixmapRequestsStack.isEmpty() && !request )
     {
         PixmapRequest * r = d->pixmapRequestsStack.last();
-        // request only if page isn't already present
-        if ( r->page->hasPixmap( r->id, r->width, r->height ) )
+        // request only if page isn't already present or request has invalid id
+        if ( r->page->hasPixmap( r->id, r->width, r->height ) || r->id <= 0 || r->id \
>= MAX_OBSERVER_ID)  {
             d->pixmapRequestsStack.pop_back();
             delete r;
--- trunk/playground/graphics/oKular/kpdf/core/observer.h #509916:509917
@@ -23,6 +23,8 @@
 #define MINIBAR_ID 6
 #define REVIEWS_ID 7
 
+// the biggest ide, useful for ignoring wrong id request
+#define MAX_OBSERVER_ID 8
 /** PRIORITIES for requests. Globally defined here. **/
 #define PAGEVIEW_PRIO 1
 #define PAGEVIEW_PRELOAD_PRIO 3
--- trunk/playground/graphics/oKular/kpdf/generators/ghostview/generator_ghostview.cpp \
#509916:509917 @@ -47,6 +47,10 @@
     m_paperSize = 0;
     dscForPDF = 0;
     m_asyncBusy = false;
+    m_sRequest=0;
+    m_asRequest=0;
+    syncLock.unlock();
+    docLock.unlock();
     if ( GSSettings::messages() )
     {
         m_logWindow = new GSLogWindow(QString ("Logwindow"));
@@ -217,14 +221,16 @@
 
 void GSGenerator::slotPixmapGenerated(const QImage* img)
 {
-    syncLock.unlock();
     kdWarning() << "SlotSyncGenerated! - finished m_sRequest id=" << m_sRequest->id \
<< " " <<m_sRequest->width << "x" << m_sRequest->height << "@" << \
m_sRequest->pageNumber << " async == " << m_sRequest->async << endl; +    kdWarning() \
<< "sync gen is ready:" << pixGenerator->ready() << endl;  QPixmap * rPix;
     rPix = new QPixmap(img->size());
     rPix->fill();
     QPainter p(rPix);
     p.drawImage(0,0,*img,0,0,img->width(),img->height());
     p.end();
+    kdWarning() << "unlocking \n";
+    syncLock.unlock();
     m_sRequest->page->setPixmap( m_sRequest->id, rPix );
     signalRequestDone( m_sRequest );
 }
@@ -328,14 +334,12 @@
 {
     if (! pixGenerator->running())
     {
-        if( pixGenerator->start() && internalDoc->dsc()->isStructured() )
+        if( pixGenerator->start(true) && internalDoc->dsc()->isStructured() )
         {
-            
+            kdWarning() << "setStructure\n";
             // this 0 is ok here, we will not be getting a PAGE anwser from those
             pixGenerator->run ( internalDoc->file() , internalDoc->prolog(), false);
-            pixGenerator->unlock();
             pixGenerator->run ( internalDoc->file() , internalDoc->setup(), false );
-            pixGenerator->unlock();
         }
     }
     return pixGenerator->running();
@@ -353,10 +357,11 @@
 {
     kdWarning() << "receiving req id=" << req->id << " " <<req->width << "x" << \
req->height << "@" << req->pageNumber << " async == " << req->async << endl;  int \
                pgNo=req->pageNumber;
-    if ( false )
+    if (!req->async)
+      return;
+    if ( req->async )
     {
         docLock.lock();
-        return ;
         m_asRequest=req;
         kdWarning() << "setOrientation\n";
         asyncGenerator->setOrientation(rotation (internalDoc->orientation(pgNo)));
@@ -388,23 +393,31 @@
     }
     else
     {
+
       syncLock.lock();
-       disconnect (pixGenerator, SIGNAL (Finished(const QImage*)),
-         this, SLOT(slotPixmapGenerated (const QImage*)));
-      m_sRequest=req;
-      pixGenerator->setOrientation(rotation (internalDoc->orientation(pgNo)));
-  //     pixGenerator->setBoundingBox( internalDoc->boundingBox(i));
-      pixGenerator->setSize(req->width ,req->height);
+//        disconnect (pixGenerator, SIGNAL (Finished(const QImage*)),
+//          this, SLOT(slotPixmapGenerated (const QImage*)));
+
       pixGenerator->setMedia( internalDoc -> getPaperSize ( internalDoc -> \
                pageMedia( pgNo )) );
       pixGenerator->setMagnify(QMAX(static_cast<double>(req->width)/req->page->width() \
,  static_cast<double>(req->height)/req->page->height()));
+      pixGenerator->setOrientation(rotation (internalDoc->orientation(pgNo)));
+      pixGenerator->setSize(req->width ,req->height);
+  //     pixGenerator->setBoundingBox( internalDoc->boundingBox(i));
+      
+      
+      
       if (!pixGenerator->running())
       {
         initInterpreter();
       }
-       connect (pixGenerator, SIGNAL (Finished(const QImage*)),
-         this, SLOT(slotPixmapGenerated (const QImage*)));
-      pixGenerator->run ( internalDoc->file() , internalDoc->pagePos(pgNo));
+/*       connect (pixGenerator, SIGNAL (Finished(const QImage*)),
+         this, SLOT(slotPixmapGenerated (const QImage*)));*/
+      this->m_sRequest=req;
+kdWarning() << "checking req id=" << req->id << " " <<req->width << "x" << \
req->height << "@" << req->pageNumber << " async == " << req->async << endl; \
+kdWarning() << "generator running : " << pixGenerator->running() << endl; +      \
pixGenerator->run ( internalDoc->file() , internalDoc->pagePos(pgNo),true); +      
     }
 }
 
@@ -412,8 +425,8 @@
 bool GSGenerator::canGeneratePixmap( bool async )
 {
 //     kdWarning () << "ready Async/Sync " << (! docLock.locked()) << "/ " << (( \
pixGenerator ) ? !syncLock.locked() : true) << " asking for async: " << async << \
                endl;
-//     if (async) return false;
-    return ( pixGenerator ) ? ! syncLock.locked() : true;
+    if (async) return !docLock.locked();
+    return ( pixGenerator ) ?  pixGenerator->ready() && !syncLock.locked() : true;
 }
 
 const DocumentInfo * GSGenerator::generateDocumentInfo()
--- trunk/playground/graphics/oKular/kpdf/generators/ghostview/interpreter_cmd.cpp \
#509916:509917 @@ -397,7 +397,7 @@
 {
     if (e->type() == GS_DATAREADY_ID )
     {
-        kdDebug(4655) << "emitting signal" << endl;
+        kdWarning() << "emitting signal" << endl;
         QPixmap *pix=takePixmap();
   
         emit Finished(pix);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic