[KDev4] DUChainViewer crashes when closing a project.

dukju ahn dukjuahn at gmail.com
Fri Jul 6 15:39:47 UTC 2007


The situation is regarding duchain viewer model. When we
unload project, projectmanagerview plugin is removed from
right side docking widget (see stack#28) and then it seems
that Qt tries to set focus on DUChain Viewer.( at least
DuChainModel::parent() is called ). The dynamic_cast in
duchainmodel fails due to some reason.

Can anyone fix it? I guess the object becomes invalid during
closing the file and invalid objects are being dynamic_casted.
But I don't have any knowledge on cpp part. That's just my
imagination.
-------------- next part --------------
QModelIndex DUChainModel::parent(const QModelIndex & index) const
{
  if (!index.isValid())
    return QModelIndex();

  DUChainReadLocker readLock(DUChain::lock());
  QMutexLocker lock(&m_mutex);

  DUChainBase* base = objectForIndex(index);
  if (!base)
    return QModelIndex();

  if (ProxyObject* proxy = dynamic_cast<ProxyObject*>(base)) <<==== this line dynamic_cast crashes.
    return createParentIndex(proxy->parent);

  if (DUContext* context = dynamic_cast<DUContext*>(base))
    if (context && context->parentContext())
      return createParentIndex(context->parentContext());
    else
      return QModelIndex();

  if (Declaration* dec = dynamic_cast<Declaration*>(base))
    return createParentIndex(dec->context());

  if (Definition* def = dynamic_cast<Definition*>(base))
    return createParentIndex(def->declaration());

  if (Use* use = dynamic_cast<Use*>(base))
    return createParentIndex(use->declaration());

  // Shouldn't really hit this
  //Q_ASSERT(false);
  return QModelIndex();
}
gdb /home/kdev/usr/bin/kdevelop --interpreter=mi2 -quiet
Quit
<font color="blue">(gdb) bt</font>
bt
#0  0x00002aaaaab04420 in ?? ()
#1  0x00002ae012bc5821 in __dynamic_cast () from /usr/lib64/libstdc++.so.6
#2  0x00002ae01a1fdef0 in DUChainModel::parent (this=0xb042f0, index=@0xc6bf80) at /home/kdev/ktrunk/kdevplatform/plugins/duchainviewer/duchainmodel.cpp:137
#3  0x00002ae01251160b in QModelIndex::parent (this=0xc6bf80) at ../../include/QtCore/../../src/corelib/kernel/qabstractitemmodel.h:337
#4  0x00002ae012647f0b in QHeaderView::currentChanged (this=0xaff070, current=@0xc6bf80, old=@0x2ae00ed869f0) at itemviews/qheaderview.cpp:1779
#5  0x00002ae01263e45d in QAbstractItemView::qt_metacall (this=0xaff070, _c=QMetaObject::InvokeMetaMethod, _id=20, _a=0x7fff9c0f9640) at .moc/debug-shared/moc_qabstractitemview.cpp:223
#6  0x00002ae01264bf80 in QHeaderView::qt_metacall (this=0xaff070, _c=QMetaObject::InvokeMetaMethod, _id=51, _a=0x7fff9c0f9640) at .moc/debug-shared/moc_qheaderview.cpp:130
#7  0x00002ae00ebd0836 in QMetaObject::activate (sender=0xb06a80, from_signal_index=5, to_signal_index=5, argv=0x7fff9c0f9640) at kernel/qobject.cpp:3063
#8  0x00002ae00ebd0c2d in QMetaObject::activate (sender=0xb06a80, m=0x2ae0129e1580, local_signal_index=1, argv=0x7fff9c0f9640) at kernel/qobject.cpp:3125
#9  0x00002ae01267e76b in QItemSelectionModel::currentChanged (this=0xb06a80, _t1=@0xc6bf80, _t2=@0x2ae00ed869f0) at .moc/debug-shared/moc_qitemselectionmodel.cpp:150
#10 0x00002ae01267f440 in QItemSelectionModel::setCurrentIndex (this=0xb06a80, index=@0x7fff9c0f9730, command=@0x7fff9c0f9720) at itemviews/qitemselectionmodel.cpp:1070
#11 0x00002ae01263b2f6 in QAbstractItemView::focusInEvent (this=0x7cec90, event=0x7fff9c0fa100) at itemviews/qabstractitemview.cpp:1818
#12 0x00002ae01221a2e7 in QWidget::event (this=0x7cec90, event=0x7fff9c0fa100) at kernel/qwidget.cpp:6128
#13 0x00002ae012536abb in QFrame::event (this=0x7cec90, e=0x7fff9c0fa100) at widgets/qframe.cpp:642
#14 0x00002ae0125bb521 in QAbstractScrollArea::event (this=0x7cec90, e=0x7fff9c0fa100) at widgets/qabstractscrollarea.cpp:861
#15 0x00002ae01263cc9e in QAbstractItemView::event (this=0x7cec90, event=0x7fff9c0fa100) at itemviews/qabstractitemview.cpp:1273
#16 0x00002ae0121cdb03 in QApplicationPrivate::notify_helper (this=0x517990, receiver=0x7cec90, e=0x7fff9c0fa100) at kernel/qapplication.cpp:3538
#17 0x00002ae0121cf837 in QApplication::notify (this=0x7fff9c0fbae0, receiver=0x7cec90, e=0x7fff9c0fa100) at kernel/qapplication.cpp:3479
#18 0x00002ae00fd8b400 in KApplication::notify (this=0x7fff9c0fbae0, receiver=0x7cec90, event=0x7fff9c0fa100) at /home/kdev/ktrunk/kdelibs/kdeui/kernel/kapplication.cpp:291
#19 0x00002ae00ebbfb9c in QCoreApplication::notifyInternal (this=0x7fff9c0fbae0, receiver=0x7cec90, event=0x7fff9c0fa100) at kernel/qcoreapplication.cpp:516
#20 0x00002ae0121cae23 in QCoreApplication::sendEvent (receiver=0x7cec90, event=0x7fff9c0fa100) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:186
#21 0x00002ae0121d08c2 in QApplicationPrivate::setFocusWidget (focus=0x7cec90, reason=Qt::TabFocusReason) at kernel/qapplication.cpp:1888
#22 0x00002ae01221476b in QWidget::setFocus (this=0x7cec90, reason=Qt::TabFocusReason) at kernel/qwidget.cpp:4429
#23 0x00002ae01221484e in QWidget::focusNextPrevChild (this=0x5e27f0, next=true) at kernel/qwidget.cpp:4537
#24 0x00002ae012214803 in QWidget::focusNextPrevChild (this=0xafa830, next=true) at kernel/qwidget.cpp:4532
#25 0x00002ae0122172df in QWidgetPrivate::hide_helper (this=0xafa860) at kernel/qwidget.cpp:5408
#26 0x00002ae01221eb60 in QWidget::setVisible (this=0xafa830, visible=false) at kernel/qwidget.cpp:5551
#27 0x00002ae0122057e7 in QWidget::hide (this=0xafa830) at ../../include/QtGui/../../src/gui/kernel/qwidget.h:436
#28 0x00002ae012551b26 in QMainWindow::removeDockWidget (this=0x5e27f0, dockwidget=0xafa830) at widgets/qmainwindow.cpp:941
#29 0x00002ae013c52787 in Sublime::MainWindowPrivate::aboutToRemoveToolView (this=0x7193a0, toolView=0xad6400) at /home/kdev/ktrunk/kdevplatform/sublime/mainwindow_p.cpp:275
#30 0x00002ae013c50658 in Sublime::MainWindow::qt_metacall (this=0x5e27f0, _c=QMetaObject::InvokeMetaMethod, _id=7, _a=0x7fff9c0faa20) at /home/kdev/ktrunk/kdevplatform/bld/sublime/mainwindow.moc:89
#31 0x00002ae00fa815b3 in KDevelop::MainWindow::qt_metacall (this=0x5e27f0, _c=QMetaObject::InvokeMetaMethod, _id=53, _a=0x7fff9c0faa20) at /home/kdev/ktrunk/kdevplatform/bld/shell/mainwindow.moc:70
#32 0x00002ae00ebd0836 in QMetaObject::activate (sender=0x5e0b30, from_signal_index=7, to_signal_index=7, argv=0x7fff9c0faa20) at kernel/qobject.cpp:3063
#33 0x00002ae00ebd0c2d in QMetaObject::activate (sender=0x5e0b30, m=0x2ae013d5dd00, local_signal_index=3, argv=0x7fff9c0faa20) at kernel/qobject.cpp:3125
#34 0x00002ae013c48854 in Sublime::Area::aboutToRemoveToolView (this=0x5e0b30, _t1=0xad6400, _t2=Sublime::Right) at /home/kdev/ktrunk/kdevplatform/bld/sublime/area.moc:106
#35 0x00002ae013c48c29 in Sublime::Area::removeToolView (this=0x5e0b30, view=0xad6400) at /home/kdev/ktrunk/kdevplatform/sublime/area.cpp:181
#36 0x00002ae00fa90fa4 in KDevelop::UiController::removeToolView (this=0x5f0fa0, factory=0xab5ec0) at /home/kdev/ktrunk/kdevplatform/shell/uicontroller.cpp:141
#37 0x00002ae01a0edff9 in ProjectManagerViewPart::unload (this=0xae2130) at /home/kdev/ktrunk/kdevplatform/plugins/projectmanagerview/projectmanagerview_part.cpp:152
#38 0x00002ae00fa8597a in KDevelop::PluginController::unloadPlugin (this=0x723eb0, pluginId=@0x7fff9c0fac10) at /home/kdev/ktrunk/kdevplatform/shell/plugincontroller.cpp:201
#39 0x00002ae00fa8715b in KDevelop::PluginController::unloadPlugins (this=0x723eb0, type=KDevelop::IPluginController::Project) at /home/kdev/ktrunk/kdevplatform/shell/plugincontroller.cpp:187
#40 0x00002ae00fa936a0 in KDevelop::ProjectController::closeProject (this=0x75b7d0, proj=0xb04df0) at /home/kdev/ktrunk/kdevplatform/shell/projectcontroller.cpp:371
#41 0x00002ae01a0edfb5 in ProjectManagerViewPart::slotCloseProject (this=0xae2130) at /home/kdev/ktrunk/kdevplatform/plugins/projectmanagerview/projectmanagerview_part.cpp:232
#42 0x00002ae01a0ee8da in ProjectManagerViewPart::qt_metacall (this=0xae2130, _c=QMetaObject::InvokeMetaMethod, _id=6, _a=0x2aaaaab6cbe0) at /home/kdev/ktrunk/kdevplatform/bld/plugins/projectmanagerview/projectmanagerview_part.moc:86
#43 0x00002ae00ebcc741 in QMetaCallEvent::placeMetaCall (this=0x2aaaaab8d3f0, object=0xae2130) at kernel/qobject.cpp:523
#44 0x00002ae00ebd14a1 in QObject::event (this=0xae2130, e=0x2aaaaab8d3f0) at kernel/qobject.cpp:1107
#45 0x00002ae0121cdb03 in QApplicationPrivate::notify_helper (this=0x517990, receiver=0xae2130, e=0x2aaaaab8d3f0) at kernel/qapplication.cpp:3538
#46 0x00002ae0121cde25 in QApplication::notify (this=0x7fff9c0fbae0, receiver=0xae2130, e=0x2aaaaab8d3f0) at kernel/qapplication.cpp:3097
#47 0x00002ae00fd8b400 in KApplication::notify (this=0x7fff9c0fbae0, receiver=0xae2130, event=0x2aaaaab8d3f0) at /home/kdev/ktrunk/kdelibs/kdeui/kernel/kapplication.cpp:291
#48 0x00002ae00ebbfb9c in QCoreApplication::notifyInternal (this=0x7fff9c0fbae0, receiver=0xae2130, event=0x2aaaaab8d3f0) at kernel/qcoreapplication.cpp:516
#49 0x00002ae00ebc2dd1 in QCoreApplication::sendEvent (receiver=0xae2130, event=0x2aaaaab8d3f0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:186
#50 0x00002ae00ebc00e8 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x517360) at kernel/qcoreapplication.cpp:1090
#51 0x00002ae00ebc0244 in QCoreApplication::sendPostedEvents (receiver=0x0, event_type=-1) at kernel/qcoreapplication.cpp:978
#52 0x00002ae00ebe7a24 in postEventSourceDispatch (s=0x522920) at kernel/qeventdispatcher_glib.cpp:194
#53 0x00002ae013306913 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
#54 0x00002ae01330975d in ?? () from /usr/lib64/libglib-2.0.so.0
#55 0x00002ae013309c7e in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
#56 0x00002ae00ebe6ffa in QEventDispatcherGlib::processEvents (this=0x517850, flags=@0x7fff9c0fb950) at kernel/qeventdispatcher_glib.cpp:325
#57 0x00002ae01225b453 in QGuiEventDispatcherGlib::processEvents (this=0x517850, flags=@0x7fff9c0fb9a0) at kernel/qguieventdispatcher_glib.cpp:178
#58 0x00002ae00ebbce79 in QEventLoop::processEvents (this=0x7fff9c0fba50, flags=@0x7fff9c0fba00) at kernel/qeventloop.cpp:126
#59 0x00002ae00ebbcfce in QEventLoop::exec (this=0x7fff9c0fba50, flags=@0x7fff9c0fba60) at kernel/qeventloop.cpp:168
#60 0x00002ae00ebc0350 in QCoreApplication::exec () at kernel/qcoreapplication.cpp:736
#61 0x00002ae0121cd6dc in QApplication::exec () at kernel/qapplication.cpp:3035
#62 0x0000000000405f47 in main (argc=1, argv=0x7fff9c0fc968) at /home/kdev/ktrunk/kdevelop2/src/main.cpp:184
^done


More information about the KDevelop-devel mailing list