Bug 68029 - closing of second window closes all windows
Summary: closing of second window closes all windows
Status: RESOLVED FIXED
Alias: None
Product: kword
Classification: Miscellaneous
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Thomas Zander
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-12 18:06 UTC by Mikolaj Machowski
Modified: 2003-11-15 03:48 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 Mikolaj Machowski 2003-11-12 18:06:31 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.3.1 
OS:          Linux

I open one instance of kword, then Ctrl-O, and when clicking on close
button of the second document everything is closed.
Comment 1 David Faure 2003-11-12 21:32:48 UTC
Subject: Re:  New: closing of second window closes all windows

On Wednesday 12 November 2003 18:06, you wrote:
> I open one instance of kword, then Ctrl-O, and when clicking on close
> button of the second document everything is closed.

This means KFileDialog crashed - duplicate of #66142
Did you get that crash with the current CVS HEAD version of KOffice?
If so, can you provide a backtrace? The bug is supposed to be fixed...

Comment 2 Mikolaj Machowski 2003-11-13 02:55:55 UTC
Subject: Re:  closing of second window closes all windows

> > I open one instance of kword, then Ctrl-O, and when clicking on close
> > button of the second document everything is closed.
>
> This means KFileDialog crashed - duplicate of #66142
> Did you get that crash with the current CVS HEAD version of KOffice?
> If so, can you provide a backtrace? The bug is supposed to be fixed...

Sorry, I wasn't precise enough.
1. Open Kword
2. Open document
3. Ctrl+O/Open recent, choose document, open it, KFileDialog closes (no 
crash)
4. I have two documents in two windows.

And here fun begins:
a) Close second window with titlebar button:
	both windows close (as with Quit action)
b) Close second window with Close action:
	first window close and in second I am getting KFileDialog as for new
	document (three tabs)
c) Close second window with Quit action:
	both windows close
	
When performing this actions with first window everything works OK.
One could suspect problems could be with closing of first window (as
mother process)...

3a. New document
4a. I have two documents in two windows.

Fun:
a) Close second window with titlebar button:
	second window closes
b) Close second window with Close action:
	I am getting KFileDialog as for new document (three tabs)
c) Close second window with Quit action:
	only second window closes

A-ha. But here is crash also:
Repeat 1., 2., 3a., 4a.

5a. Insert some text
6a. Close action, discard changes
Backtrace (but couldn't reproduce crash):
0x41534656 in waitpid () from /lib/i686/libpthread.so.0
#0  0x41534656 in waitpid () from /lib/i686/libpthread.so.0
#1  0x40ac256f in KCrash::defaultCrashHandler(int) ()
   from /usr/local/kde/lib/libkdecore.so.4
#2  0x415334ec in __pthread_clock_settime () from /lib/i686/libpthread.so.0
#3  0x415d5ca8 in __libc_sigaction () from /lib/i686/libc.so.6
#4  0x410ef99b in QGList::clear() ()
   from /usr/local/qt-x11-free-3.2.0/lib/libqt-mt.so.3
#5  0x40050dc0 in KoDocument::~KoDocument() ()
   from /usr/local/kde/lib/libkofficecore.so.2
#6  0x41975d5b in KWDocument::~KWDocument() ()
   from /usr/local/kde/lib/kde3/libkwordpart.so
#7  0x40806cce in QPtrList<QObject>::deleteItem(void*) ()
   from /usr/local/kde/lib/libkdeui.so.4
#8  0x410ef99b in QGList::clear() ()
   from /usr/local/qt-x11-free-3.2.0/lib/libqt-mt.so.3
#9  0x40add33f in KLibrary::~KLibrary() ()
   from /usr/local/kde/lib/libkdecore.so.4
#10 0x40ae0178 in KLibLoader::close_pending(KLibWrapPrivate*) ()
   from /usr/local/kde/lib/libkdecore.so.4
#11 0x40adedc2 in KLibLoader::~KLibLoader() ()
   from /usr/local/kde/lib/libkdecore.so.4
#12 0x40addddd in KLibLoader::cleanUp() ()
   from /usr/local/kde/lib/libkdecore.so.4
#13 0x40a22da7 in KApplication::~KApplication() ()
   from /usr/local/kde/lib/libkdecore.so.4
#14 0x40075053 in KoApplication::~KoApplication() ()
   from /usr/local/kde/lib/libkofficecore.so.2
#15 0x4001645e in main () from /usr/local/kde/lib/kword.so
#16 0x415c2c57 in __libc_start_main () from /lib/i686/libc.so.6

Also there are variations if first document was new.

Comment 3 David Faure 2003-11-15 03:48:58 UTC
Subject: koffice/lib/kofficecore

CVS commit by faure: 

Remove document from its "creator" mainwindow if we're giving it its own mainwindow
(as happens when opening a new doc from an existing mainwindow)
(the real fix is the koMainWindow one-liner)
CCMAIL: 68029-done@bugs.kde.org


  M +7 -2      koDocument.cc   1.286
  M +1 -0      koMainWindow.cc   1.317


--- koffice/lib/kofficecore/koDocument.cc  #1.285:1.286
@@ -278,5 +278,5 @@ KoDocument::~KoDocument()
     s_documentList->removeRef(this);
     // last one?
-    if(s_documentList->count()==0) {
+    if(s_documentList->isEmpty()) {
         delete s_documentList;
         s_documentList=0;
@@ -1845,9 +1845,14 @@ QCString KoDocument::readNativeFormatMim
 void KoDocument::addShell( KoMainWindow *shell )
 {
+    if ( d->m_shells.findRef( shell ) == -1 )
+    {
+        //kdDebug(30003) << "addShell: shell " << (void*)shell << " added to doc " << this << endl;
     d->m_shells.append( shell );
+    }
 }
 
 void KoDocument::removeShell( KoMainWindow *shell )
 {
+    //kdDebug(30003) << "removeShell: shell " << (void*)shell << " removed from doc " << this << endl;
     d->m_shells.removeRef( shell );
 }

--- koffice/lib/kofficecore/koMainWindow.cc  #1.316:1.317
@@ -645,4 +645,5 @@ void KoMainWindow::slotLoadCompleted()
         KoMainWindow *s = new KoMainWindow( newdoc->instance() );
         s->show();
+        newdoc->removeShell( this );
         s->setRootDocument( newdoc );
     }