Bug 143612 - Konqueror crashes when searching text in a already closed PDF document
Summary: Konqueror crashes when searching text in a already closed PDF document
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-30 01:20 UTC by Krzysztof Sroka
Modified: 2007-03-30 19:29 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krzysztof Sroka 2007-03-30 01:20:28 UTC
Version:            (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages
Compiler:          gcc 4.1.2 
OS:                Linux

This happens when searching a pdf file for text with the embedded PDF viewer.
During the search a user can close the tab containing pdf document. That doesn't close remaining search dialogs for that PDF (like 'No more occurences found' and others). Pressing button in a dialog crashes current konqueror instance.

This may happen with other operations that leave active dialogs after the PDF document is closed.

How to reproduce:
1) Run konqueror and open a tab (so that there are two tabs present).
2) Open a PDF document in one of the tabs (with the embedded PDF viewer).
3) Search for some text in the PDF document (preferably unique).
4) Continue searching until a dialog appears with 'End of document reached' information (or any other text concerning the search).
5) Ignore the dialog and close the tab with PDF. The dialog should remain active.
6) Press any button of the dialog.

Expected behaviour:
Dialogs concerning the PDF document are closed when the document's tab is closed.
Comment 1 Tommi Tervo 2007-03-30 08:07:32 UTC
svn r643679

#6  0xb4de748f in KPDFDocument::searchText (this=0x89141d0, searchID=1, 
    text=@0x8515c50, fromStart=false, caseSensitive=false, type=NextMatch, 
    moveViewport=true, color=@0x8515c5c, noDialogs=false) at document.cpp:751
#7  0xb4de7d18 in KPDFDocument::continueSearch (this=0x89141d0, searchID=1)
    at document.cpp:889
#8  0xb4de7d58 in KPDFDocument::continueLastSearch (this=0x89141d0)
    at document.cpp:920
#9  0xb4cd81cc in KPDF::Part::slotFindNext (this=0x852fc38) at part.cpp:744
#10 0xb4cdf3ad in KPDF::Part::qt_invoke (this=0x852fc38, _id=14, _o=0xbf9ce13c)
    at part.moc:198
#11 0xb71b6aa9 in QObject::activate_signal ()
   from /usr/share/qt3/lib/libqt-mt.so.3
#12 0xb71b7544 in QObject::activate_signal ()
   from /usr/share/qt3/lib/libqt-mt.so.3
Comment 2 Philip Rodrigues 2007-03-30 09:42:52 UTC
I get the same backtrace, but with a tiny bit more at the beginning:

#20 0x2a53bf6b in QValueVectorPrivate (this=0x8726af8, x=@0x86c81e0)
    at qvaluevector.h:124
#21 0x2a53b609 in QValueVector<KPDFPage*>::detachInternal (this=0x86df644)
    at qvaluevector.h:499
#22 0x2a53a17c in QValueVector<KPDFPage*>::detach (this=0x86df644)
    at qvaluevector.h:479
#23 0x2a53912e in QValueVector<KPDFPage*>::operator[] (this=0x86df644, i=0)
    at qvaluevector.h:357
#24 0x2a5332e4 in KPDFDocument::searchText (this=0x86df618, searchID=1, 
    text=@0x86a0928, fromStart=false, caseSensitive=false, type=NextMatch, 
    moveViewport=true, color=@0x86a0934, noDialogs=false)
    at /home/phil/kdesrc/kdegraphics/kpdf/core/document.cpp:751

...and then the same as Tommi
Comment 3 Albert Astals Cid 2007-03-30 19:29:34 UTC
SVN commit 648173 by aacid:

Give KMessageBoxes a parent widget.
BUGS: 143612


 M  +12 -7     core/document.cpp  
 M  +4 -1      core/document.h  
 M  +1 -1      core/generator_pdf/generator_pdf.cpp  
 M  +1 -1      part.cpp  


--- branches/KDE/3.5/kdegraphics/kpdf/core/document.cpp #648172:648173
@@ -106,8 +106,8 @@
 
 /** KPDFDocument **/
 
-KPDFDocument::KPDFDocument()
-    : generator( 0 ), d( new KPDFDocumentPrivate )
+KPDFDocument::KPDFDocument(QWidget *widget)
+    : QObject(widget), generator( 0 ), d( new KPDFDocumentPrivate )
 {
     d->allocatedPixmapsTotalMemory = 0;
     d->memCheckTimer = 0;
@@ -355,6 +355,11 @@
 }
 
 
+QWidget *KPDFDocument::widget() const
+{
+    return static_cast<QWidget*>(parent());
+}
+
 bool KPDFDocument::isOpened() const
 {
     return generator;
@@ -742,7 +747,7 @@
             {
                 if ( currentPage >= pageCount )
                 {
-                    if ( noDialogs || KMessageBox::questionYesNo(0, i18n("End of document reached.\nContinue from the beginning?"), QString::null, KStdGuiItem::cont(), KStdGuiItem::cancel()) == KMessageBox::Yes )
+                    if ( noDialogs || KMessageBox::questionYesNo(widget(), i18n("End of document reached.\nContinue from the beginning?"), QString::null, KStdGuiItem::cont(), KStdGuiItem::cancel()) == KMessageBox::Yes )
                         currentPage = 0;
                     else
                         break;
@@ -788,7 +793,7 @@
             }
         }
         else if ( !noDialogs )
-            KMessageBox::information( 0, i18n("No matches found for '%1'.").arg( text ) );
+            KMessageBox::information( widget(), i18n("No matches found for '%1'.").arg( text ) );
     }
     // 3. PREVMATCH //TODO
     else if ( type == PrevMatch )
@@ -990,7 +995,7 @@
                     {
                         // this case is a link pointing to an executable with a parameter
                         // that also is an executable, possibly a hand-crafted pdf
-                        KMessageBox::information( 0, i18n("The pdf file is trying to execute an external application and for your safety kpdf does not allow that.") );
+                        KMessageBox::information( widget(), i18n("The pdf file is trying to execute an external application and for your safety kpdf does not allow that.") );
                         return;
                     }
                 }
@@ -998,7 +1003,7 @@
                 {
                     // this case is a link pointing to an executable with no parameters
                     // core developers find unacceptable executing it even after asking the user
-                    KMessageBox::information( 0, i18n("The pdf file is trying to execute an external application and for your safety kpdf does not allow that.") );
+                    KMessageBox::information( widget(), i18n("The pdf file is trying to execute an external application and for your safety kpdf does not allow that.") );
                     return;
                 }
             }
@@ -1011,7 +1016,7 @@
                 KRun::run( *ptr, lst );
             }
             else
-                KMessageBox::information( 0, i18n( "No application found for opening file of mimetype %1." ).arg( mime->name() ) );
+                KMessageBox::information( widget(), i18n( "No application found for opening file of mimetype %1." ).arg( mime->name() ) );
             } break;
 
         case KPDFLink::Action: {
--- branches/KDE/3.5/kdegraphics/kpdf/core/document.h #648172:648173
@@ -51,7 +51,7 @@
 {
     Q_OBJECT
     public:
-        KPDFDocument();
+        KPDFDocument( QWidget *widget );
         ~KPDFDocument();
 
         // document handling
@@ -66,6 +66,9 @@
         // enum definitions
         enum Permission { AllowModify = 1, AllowCopy = 2, AllowPrint = 4, AllowNotes = 8 };
 
+        // returns the widget where the document is shown
+        QWidget *widget() const;
+
         // query methods (const ones)
         bool isOpened() const;
         const DocumentInfo * documentInfo() const;
--- branches/KDE/3.5/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp #648172:648173
@@ -466,7 +466,7 @@
         double yScale = ((double)paperHeight - (double)marginBottom - (double)marginTop) / (double)paperHeight;
 
         if ( abs((int)(xScale * 100) - (int)(yScale * 100)) > 5 ) {
-            int result = KMessageBox::questionYesNo(0,
+            int result = KMessageBox::questionYesNo(m_document->widget(),
                                        i18n("The margins you specified change the page aspect ratio. Do you want to print with the aspect ratio changed or do you want the margins to be adapted so that the aspect ratio is preserved?"),
                                        i18n("Aspect ratio change"),
                                        i18n("Print with specified margins"),
--- branches/KDE/3.5/kdegraphics/kpdf/part.cpp #648172:648173
@@ -110,7 +110,7 @@
 	setInstance(KPDFPartFactory::instance());
 
 	// build the document
-	m_document = new KPDFDocument();
+	m_document = new KPDFDocument(widget());
 	connect( m_document, SIGNAL( linkFind() ), this, SLOT( slotFind() ) );
 	connect( m_document, SIGNAL( linkGoToPage() ), this, SLOT( slotGoToPage() ) );
 	connect( m_document, SIGNAL( linkPresentation() ), this, SLOT( slotShowPresentation() ) );