Bug 65161 - Inserting a Karbon object frame in KWord results in a crash
Summary: Inserting a Karbon object frame in KWord results in a crash
Status: RESOLVED FIXED
Alias: None
Product: karbon
Classification: Applications
Component: general (show other bugs)
Version: 1.3
Platform: Gentoo Packages Linux
: NOR crash
Target Milestone: ---
Assignee: Rob Buis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-29 05:37 UTC by Dave Flogeras
Modified: 2004-02-11 13:49 UTC (History)
3 users (show)

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 Dave Flogeras 2003-09-29 05:37:58 UTC
Version:           unknown (using KDE 3.1.4)
Installed from:    Gentoo
Compiler:          gcc version 3.2.3 20030422 (Gentoo Linux 1.4 3.2.3-r1, propolice)
OS:          Linux (i686) release 2.4.20-gentoo-r7

To reproduce, open a blank document in Kword (1.3 beta4) insert an Object frame, select a Karbon14 object type (create an empty Karbon document), and place the frame somewhere.  Now, activate the frame, and the embedded karbon loads.  When you click off this new frame, KWord crashes.
Comment 1 Nicolas Goutte 2003-09-30 00:56:16 UTC
Moving to KWord/General (It seems that it has nothing to do with tables.) 
 
Have a nice day! 
Comment 2 Nicolas Goutte 2003-09-30 01:00:12 UTC
I have tried to reproduce it (from the A4 template.) It works for me. (KOffice 
CVS HEAD 2003-09-29; KDE KDE_3_1_BRANCH 2003-09-27; Qt 3.2 snapshot 
2003-09-24.) 
 
Have a nice day! 
Comment 3 Stefan Hetzl 2003-11-07 23:07:53 UTC
I can reproduce this with current CVS HEAD. Here is my backtrace:

[New Thread 16384 (LWP 26099)]
0x414f2387 in waitpid () from /lib/libpthread.so.0
#0  0x414f2387 in waitpid () from /lib/libpthread.so.0
#1  0x40a438b2 in KCrash::defaultCrashHandler(int) ()
   from /opt/kde-cvs/lib/libkdecore.so.4
#2  0x414f11ec in __pthread_sighandler () from /lib/libpthread.so.0
#3  <signal handler called>
#4  0x4072ae0a in KToolBar::applyAppearanceSettings(KConfig*, QString const&, bool) () from /opt/kde-cvs/lib/libkdeui.so.4
#5  0x4072b383 in KToolBar::applySettings(KConfig*, QString const&) ()
   from /opt/kde-cvs/lib/libkdeui.so.4
#6  0x40795f78 in KMainWindow::applyMainWindowSettings(KConfig*, QString const&) () from /opt/kde-cvs/lib/libkdeui.so.4
#7  0x40796e0d in KMainWindow::setAutoSaveSettings(QString const&, bool) ()
   from /opt/kde-cvs/lib/libkdeui.so.4
#8  0x40073401 in KoMainWindow::slotActivePartChanged(KParts::Part*) ()
   from /opt/kde-cvs/lib/libkofficecore.so.2
#9  0x40074940 in KoMainWindow::qt_invoke(int, QUObject*) ()
   from /opt/kde-cvs/lib/libkofficecore.so.2
#10 0x40e8937f in QObject::activate_signal(QConnectionList*, QUObject*) (
    this=0x8156848, clist=0x8134ab0, o=0xbfffe930) at kernel/qobject.cpp:2333
#11 0x401db98a in KParts::PartManager::activePartChanged(KParts::Part*) ()
   from /opt/kde-cvs/lib/libkparts.so.2
#12 0x401dac72 in KParts::PartManager::setActivePart(KParts::Part*, QWidget*)
    () from /opt/kde-cvs/lib/libkparts.so.2
#13 0x401d9942 in KParts::PartManager::eventFilter(QObject*, QEvent*) ()
   from /opt/kde-cvs/lib/libkparts.so.2
#14 0x40074fa6 in KoPartManager::eventFilter(QObject*, QEvent*) ()
   from /opt/kde-cvs/lib/libkofficecore.so.2
#15 0x40e2637b in QApplication::internalNotify(QObject*, QEvent*) (
    this=0xbffff1b0, receiver=0x82af090, e=0xbfffed70)
    at kernel/qapplication.cpp:2515
#16 0x40e25d13 in QApplication::notify(QObject*, QEvent*) (this=0xbffff1b0, 
    receiver=0x82af090, e=0xbfffed70) at kernel/qapplication.cpp:2368
#17 0x4099a323 in KApplication::notify(QObject*, QEvent*) ()
   from /opt/kde-cvs/lib/libkdecore.so.4
#18 0x40dbd493 in QApplication::sendSpontaneousEvent(QObject*, QEvent*) (
    receiver=0x82af090, event=0xbfffed70) at kernel/qapplication.h:493
#19 0x40db6c1d in QETWidget::translateMouseEvent(_XEvent const*) (
    this=0x82af090, event=0xbffff080) at kernel/qapplication_x11.cpp:4347
#20 0x40db4958 in QApplication::x11ProcessEvent(_XEvent*) (this=0xbffff1b0, 
    event=0xbffff080) at kernel/qapplication_x11.cpp:3525
#21 0x40dce5be in QEventLoop::processEvents(unsigned) (this=0x80b4ac8, flags=4)
    at kernel/qeventloop_x11.cpp:192
#22 0x40e3bf26 in QEventLoop::enterLoop() (this=0x80b4ac8)
    at kernel/qeventloop.cpp:198
#23 0x40e3be42 in QEventLoop::exec() (this=0x80b4ac8)
    at kernel/qeventloop.cpp:145
#24 0x40e266dd in QApplication::exec() (this=0xbffff1b0)
    at kernel/qapplication.cpp:2705
#25 0x4001710f in main () from /opt/kde-cvs/lib/kword.so
#26 0x41636857 in __libc_start_main () from /lib/libc.so.6

The end of the debugging output:
kword: [void KWPartFrameSet::endEditing()]
kparts: 0x8156848 emitting activePartChanged (nil)
karbon: [KPopupMenu pointer (0x83292f8) to widget edit_purge, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x82e2508) to widget edit, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x8314fa0) to widget object_order, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x8306070) to widget object_align, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x8319e18) to widget object, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x82f1778) to widget plugins, geometry=512x307+256+230]
karbon: [KPopupMenu pointer (0x82e92f0) to widget view, geometry=512x307+256+230]
karbon: [KToolBar pointer (0x82f6f00) to widget edit_toolbar, geometry=184x32+155+0]
karbon: [KToolBar pointer (0x82798f0) to widget view_toolbar, geometry=262x32+155+0]
kdeui (KToolBar): object_toolbar KToolBar::removeItem item -114 not found
karbon: [KToolBar pointer (0x8278b30) to widget object_toolbar, geometry=285x66+155+0]
karbon: [VToolBox pointer (0x834f900) to widget Tools, geometry=435x66+155+0]
karbon: [KToolBar pointer (0x83106c8) to widget align_toolbar, geometry=512x307+0+0]
kword: KoViewChild::slotFrameGeometryChanged child geometry already 65,145 239x199
karbon: **** part->paintContent()
karbon: painter.worldMatrix().dx() : 44
karbon: painter.worldMatrix().dy() : 98
karbon: rect.x() : 0
karbon: rect.y() : 0
karbon: rect.width() : 163
karbon: rect.height() : 136
karbon: Handling KarbonView dtor
koffice (lib kofficecore): KoView::~KoView [KoView pointer (0x85445e0) to unnamed widget, geometry=162x135+0+0]
karbon: KarbonPart::removeView
kword: [bool KoDocument::isModified()]  Modified doc='' extern=false
kparts: 0x8156848 emitting activePartChanged 0x8111c88
kdecore (KAction): WARNING: KAction::plug(): has no KAccel object; this = 0x81166a8 name = koffice_undo parentCollection = 0x8116468
kdecore (KAction): WARNING: KAction::plug(): has no KAccel object; this = 0x811b948 name = koffice_redo parentCollection = 0x8116468

Greetings,
Stefan
Comment 4 Dik Takken 2003-11-14 10:37:32 UTC
I can also reproduce it with KWord 1.2.94.
Comment 5 Lukáš Tinkl 2003-12-01 09:53:03 UTC
I can reproduce the same crash, although when desactivating the embedded part, not when inserting.
Comment 6 Waldo Bastian 2004-02-09 14:59:27 UTC
Still reproducable, I suspect Karbon's rather peculiar dockwindows.
Comment 7 Waldo Bastian 2004-02-09 18:01:23 UTC
The problem is caused by the XMLGUI generated "Plugins" toolbar in Karbon. When more than one plugin adds itself to this toolbar via its .rc file the problem occurs.
Comment 8 Waldo Bastian 2004-02-10 18:37:16 UTC
The problem is that the Plugins toolbar gets a KXMLGUIClient that is associated with one of the plugins and when the part is switched from karbon to kword, the plugin and KXMGUIClient is deleted but the Plugins toolbar remains around with a stale d->m_xmlguiClient pointer.

It seems that this can be worked around by defining the Plugins toolbar in the
karbon.rc file.
Comment 9 Waldo Bastian 2004-02-10 21:35:48 UTC
Another problem is then that activating the karbon part for a second time causes a crash because the "Image Tool" VTool object and the "Zoom Tool" VTool object are getting deleted when the kword part is activated but VToolController keeps the old VTool objects around.
Comment 10 Rob Buis 2004-02-10 21:46:45 UTC
Waldo,

Thank you for the investigations.
I came pretty much to the same conclusions.
I got it working better some time ago using this code :

Index: data/karbon.rc
===================================================================
RCS file: /home/kde/koffice/karbon/data/karbon.rc,v
retrieving revision 1.80.2.2
diff -u -3 -p -p -u -b -r1.80.2.2 karbon.rc
--- data/karbon.rc      21 Dec 2003 14:15:27 -0000      1.80.2.2
+++ data/karbon.rc      10 Feb 2004 20:41:25 -0000
@@ -100,6 +100,9 @@
        <ToolBar name="Tools" position="left">
                <Text>Toolbox</Text>
        </ToolBar>
+       <ToolBar name="Plugins">
+               <Text>Plugins</Text>
+       </ToolBar>
        <ToolBar name="align_toolbar" hidden="true" fullWidth="false">
                <Text>Align</Text>
                <Action name="object_align_horizontal_left"/>
Index: plugins/roundcorners/roundcornersplugin.rc
===================================================================
RCS file: /home/kde/koffice/karbon/plugins/roundcorners/roundcornersplugin.rc,v
retrieving revision 1.3
diff -u -3 -p -p -u -b -r1.3 roundcornersplugin.rc
--- plugins/roundcorners/roundcornersplugin.rc  9 Jun 2003 12:38:35 -0000       1.3
+++ plugins/roundcorners/roundcornersplugin.rc  10 Feb 2004 20:41:25 -0000
@@ -1,5 +1,5 @@
-<!DOCTYPE kpartgui>
-<kpartplugin name="roundcornersplugin" library="karbon_roundcornersplugin">
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="roundcornersplugin" library="karbon_roundcornersplugin">
 <MenuBar>
        <Menu name="plugins">
                <Action name="path_round_corners"/>
@@ -8,4 +8,4 @@
 <ToolBar name="Plugins" hidden="true" fullWidth="false">
        <Action name="path_round_corners"/>
 </ToolBar>
-</kpartplugin>
+</kpartgui>
Index: plugins/shadoweffect/shadoweffectplugin.rc
===================================================================
RCS file: /home/kde/koffice/karbon/plugins/shadoweffect/shadoweffectplugin.rc,v
retrieving revision 1.6
diff -u -3 -p -p -u -b -r1.6 shadoweffectplugin.rc
--- plugins/shadoweffect/shadoweffectplugin.rc  9 Jun 2003 12:38:35 -0000       1.6
+++ plugins/shadoweffect/shadoweffectplugin.rc  10 Feb 2004 20:41:25 -0000
@@ -1,5 +1,5 @@
-<!DOCTYPE kpartgui>
-<kpartplugin name="shadoweffectplugin" library="karbon_shadoweffectplugin">
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="shadoweffectplugin" library="karbon_shadoweffectplugin">
 <MenuBar>
        <Menu name="plugins">
                <Action name="object_shadow"/>
@@ -8,4 +8,4 @@
 <ToolBar name="Plugins" hidden="true" fullWidth="false">
        <Action name="object_shadow"/>
 </ToolBar>
-</kpartplugin>
+</kpartgui>
Index: plugins/zoomtool/zoomtoolplugin.rc
===================================================================
RCS file: /home/kde/koffice/karbon/plugins/zoomtool/zoomtoolplugin.rc,v
retrieving revision 1.1
diff -u -3 -p -p -u -b -r1.1 zoomtoolplugin.rc
--- plugins/zoomtool/zoomtoolplugin.rc  20 Dec 2002 16:30:45 -0000      1.1
+++ plugins/zoomtool/zoomtoolplugin.rc  10 Feb 2004 20:41:25 -0000
@@ -1,3 +1,3 @@
-<!DOCTYPE kpartgui>
-<kpartplugin name="zoomtoolplugin" library="karbon_zoomtoolplugin">
-</kpartplugin>
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd" >
+<kpartgui name="zoomtoolplugin" library="karbon_zoomtoolplugin">
+</kpartgui>

But even then, I am not sure kpartplugins are the way to go, its pretty
tricky :( Maybe I'll have to look how other koffice apps solve it...
Cheers,

Rob.
Comment 11 Waldo Bastian 2004-02-10 22:30:44 UTC
CVS commit by waba: 

Don't cause crashes when embedded in kword
CCMAIL: 65161-done@bugs.kde.org


  M +3 -0      data/karbon.rc   1.80.2.3
  M +2 -0      tools/vtool.cc   1.53.2.1
  M +13 -0     tools/vtoolcontroller.cc   1.6.2.1
  M +1 -0      tools/vtoolcontroller.h   1.3.2.1


--- koffice/karbon/data/karbon.rc  #1.80.2.2:1.80.2.3
@@ -110,3 +110,6 @@
                 <Action name="object_align_vertical_bottom"/>
         </ToolBar>
+        <ToolBar name="Plugins" hidden="true" fullWidth="false">
+                <Text>Plugins</Text>
+        </ToolBar>
 </kpartgui>

--- koffice/karbon/tools/vtool.cc  #1.53:1.53.2.1
@@ -42,4 +42,6 @@ VTool::VTool( KarbonPart *part, const ch
 VTool::~VTool()
 {
+        if (part() && part()->toolController())
+                part()->toolController()->unregisterTool( this );
         //kdDebug(38000) << "Deleting : " << name().latin1() << endl;
 }

--- koffice/karbon/tools/vtoolcontroller.cc  #1.6:1.6.2.1
@@ -106,4 +106,17 @@ VToolController::registerTool( VTool *to
 }
 
+void
+VToolController::unregisterTool( VTool *tool )
+{
+        // tool->name() is not valid in VTool destructor
+        QDictIterator<VTool> it( m_tools );
+        for( ; it.current(); ++it )
+                if (it.current() == tool)
+                {
+                        m_tools.remove(it.currentKey());
+                        return;
+                }
+}
+
 bool
 VToolController::mouseEvent( QMouseEvent* event, const KoPoint &p )

--- koffice/karbon/tools/vtoolcontroller.h  #1.3:1.3.2.1
@@ -54,4 +54,5 @@ public:
 
         void registerTool( VTool *tool );
+        void unregisterTool( VTool *tool );
 
         void setActiveTool( VTool * );


Comment 12 Waldo Bastian 2004-02-10 23:12:52 UTC
Tronical: kxmlguifactory_p.cpp:324 gives the following results here
for the Plugins toolbar (0x83bc230) :

ContainerNode::destruct: clients.count() = 4 children.count() = 0 container = 0x83bc230 client = 0x83377c0 state.guiClient = 0x83377c0
ContainerNode::destruct: clients.count() = 4 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x8355a8c
ContainerNode::destruct: clients.count() = 3 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x831da90
ContainerNode::destruct: clients.count() = 2 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x81f1428
ContainerNode::destruct: clients.count() = 1 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x8329dd8
ContainerNode::destruct: clients.count() = 0 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x833e8d0
ContainerNode::destruct: clients.count() = 0 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x839fdac
ContainerNode::destruct: clients.count() = 0 children.count() = 0 container = 0x83bc230 client = (nil) state.guiClient = 0x81d3da4

Maybe replacing
	"&& (client == state.guiClient)"
with
	"&& ((client == 0) || (client == state.guiClient))"
??

That seems to fix it just fine.
Comment 13 Simon Hausmann 2004-02-11 00:42:36 UTC
Hm, if client were a null pointer it would mean that line 341/342 were executed previously. That in turn would mean that some gui client created the toolbar and added some buttons. Then another gui client added another button. The however the first guiclient got removed and the toolbar was not removed as there was still 'content' , however the 'owner' (client var) was set to null. That in turn would mean clients got removed in the same order they were added, which is wrong. It needs to be reverse order.

Does karbon create/add/remove these plugins themself?
Comment 14 Simon Hausmann 2004-02-11 00:43:41 UTC
Taking the freedom of adding Zogje to CC :) . Bugzilla-chat, sort of. Please see comment #13.
Comment 15 Waldo Bastian 2004-02-11 13:36:21 UTC
What about this?

--- kxmlguifactory.cpp  26 Aug 2003 18:44:04 -0000      1.139
+++ kxmlguifactory.cpp  11 Feb 2004 12:35:23 -0000
@@ -322,7 +323,8 @@ void KXMLGUIFactory::removeClient( KXMLG
     {
         const QPtrList<KXMLGUIClient> *children = client->childClients();
         QPtrListIterator<KXMLGUIClient> childIt( *children );
-        for (; childIt.current(); ++childIt )
+        childIt.toLast();
+        for (; childIt.current(); --childIt )
             removeClient( childIt.current() );
     }


Comment 16 Simon Hausmann 2004-02-11 13:49:20 UTC
Ohhh, yes, that looks like the perfect fix!

/me hands his complete box of cookies to Zogje