midenok / kdevelop

https://github.com/midenok/kdevelop/wiki
Other
1 stars 0 forks source link

Wrong open dialog default directory #4

Open midenok opened 6 years ago

midenok commented 6 years ago

When no files opened in project, open dialog points to some previous directory from another session.

Reproduce 1

  1. Close all files in session, restart.
  2. In started session select project.
  3. Press Ctrl+O

    Reproduce 2

  4. Start new file.
  5. Press Ctrl+O

    Result

    Open file dialog points to some arbitrary location.

    Expected

    Dialog points to location of selected project or its item.

midenok commented 6 years ago

Ctrl+O pressed

#0  0x00007ffff2181bb0 in QFileDialog::QFileDialog(QFileDialogArgs const&) (this=0x7fffffff8f60, args=...) at dialogs/qfiledialog.cpp:367
#1  0x00007ffff21821c2 in QFileDialog::getOpenFileUrls(QWidget*, QString const&, QUrl const&, QString const&, QString*, QFlags<QFileDialog::Option>, QStringList const&) (parent=0x7b4780, caption="Open File", dir="/", filter="", selectedFilter=0x0, options=..., supportedSchemes=<empty>) at dialogs/qfiledialog.cpp:2293
#2  0x00007ffff7a5f504 in KDevelop::DocumentControllerPrivate::showOpenFile() const (this=0x9f5da0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/documentcontroller.cpp:143
#3  0x00007ffff7a62497 in KDevelop::DocumentControllerPrivate::chooseDocument() (this=0x9f5da0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/documentcontroller.cpp:149
#4  0x00007ffff7a5b974 in KDevelop::DocumentController::setupActions()::$_5::operator()() const (this=0x9c4e50) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/documentcontroller.cpp:600
#5  0x00007ffff7a5b939 in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, KDevelop::DocumentController::setupActions()::$_5>::call(KDevelop::DocumentController::setupActions()::$_5&, void**) (f=..., arg=0x7fffffff9380) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:130
#6  0x00007ffff7a5b911 in QtPrivate::Functor<KDevelop::DocumentController::setupActions()::$_5, 0>::call<QtPrivate::List<>, void>(KDevelop::DocumentController::setupActions()::$_5&, void*, void**) (f=..., arg=0x7fffffff9380) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:240
#7  0x00007ffff7a5b8bd in QtPrivate::QFunctorSlotObject<KDevelop::DocumentController::setupActions()::$_5, 0, QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x9c4e40, r=0xafd000, a=0x7fffffff9380, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:168
#8  0x00007ffff123e9ff in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fffffff9380, r=0xafd000, this=0x9c4e40) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
#9  0x00007ffff123e9ff in QMetaObject::activate(QObject*, int, int, void**) (sender=sender@entry=0x9f3260, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff9380) at kernel/qobject.cpp:3749
#10 0x00007ffff123efb7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x9f3260, m=m@entry=0x7ffff264ade0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff9380) at kernel/qobject.cpp:3628
#11 0x00007ffff1f83d82 in QAction::triggered(bool) (this=this@entry=0x9f3260, _t1=<optimized out>) at .moc/moc_qaction.cpp:371
#12 0x00007ffff1f8646c in QAction::activate(QAction::ActionEvent) (this=0x9f3260, event=<optimized out>) at kernel/qaction.cpp:1159
#13 0x00007ffff1f86d15 in QAction::event(QEvent*) (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1087
#14 0x00007ffff1f8a46c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x665930, receiver=receiver@entry=0x9f3260, e=e@entry=0x7fffffff9630) at kernel/qapplication.cpp:3717
#15 0x00007ffff1f91d34 in QApplication::notify(QObject*, QEvent*) (this=0x7fffffffbae8, receiver=0x9f3260, e=0x7fffffff9630) at kernel/qapplication.cpp:3476
#16 0x00007ffff120fde8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x9f3260, event=event@entry=0x7fffffff9630) at kernel/qcoreapplication.cpp:1018
#17 0x00007ffff17fcd77 in QCoreApplication::sendEvent(QObject*, QEvent*) (event=0x7fffffff9630, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:233
#18 0x00007ffff17fcd77 in QShortcutMap::dispatchEvent(QKeyEvent*) (this=this@entry=0x665a08, e=e@entry=0x7fffffff96e0) at kernel/qshortcutmap.cpp:674
#19 0x00007ffff17fce4a in QShortcutMap::tryShortcut(QKeyEvent*) (this=this@entry=0x665a08, e=e@entry=0x7fffffff96e0) at kernel/qshortcutmap.cpp:351
#20 0x00007ffff17ac473 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) (window=<optimized out>, window@entry=0xc84380, timestamp=105055127, keyCode=79, modifiers=..., nativeScanCode=32, nativeVirtualKey=111, nativeModifiers=4, text="\017", autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:375
#21 0x00007ffff17cb9b7 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) (e=0x7fffcc007920) at kernel/qguiapplication.cpp:2056
#22 0x00007ffff17d0a05 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (e=e@entry=0x7fffcc007920) at kernel/qguiapplication.cpp:1739
#23 0x00007ffff17a8cab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=...) at kernel/qwindowsysteminterface.cpp:939
#24 0x00007fffd4c2e5a0 in userEventSourceDispatch(GSource*, GSourceFunc, gpointer) (source=source@entry=0x69aec0) at qeventdispatcher_glib.cpp:77
#25 0x00007fffe8298fb7 in g_main_dispatch (context=0x7fffcc004fc0) at ../../../../glib/gmain.c:3148
#26 0x00007fffe8298fb7 in g_main_context_dispatch (context=context@entry=0x7fffcc004fc0) at ../../../../glib/gmain.c:3813
#27 0x00007fffe82991f0 in g_main_context_iterate (context=context@entry=0x7fffcc004fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../../glib/gmain.c:3886
#28 0x00007fffe829927c in g_main_context_iteration (context=0x7fffcc004fc0, may_block=may_block@entry=1) at ../../../../glib/gmain.c:3947
#29 0x00007ffff126847f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x69a2d0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#30 0x00007ffff120de3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffffff9aa0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#31 0x00007ffff1216da4 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1291
#32 0x000000000040db91 in main(int, char**) (argc=3, argv=0x7fffffffbc58) at /home/midenok/src/kde/kdevelop/stable/kdevelop/app/main.cpp:784
midenok commented 6 years ago

KDevelop::DocumentControllerPrivate::showOpenFile() dir logic

    OpenFileResult showOpenFile() const
    {
        QUrl dir;
        if ( controller->activeDocument() ) {
            dir = controller->activeDocument()->url().adjusted(QUrl::RemoveFilename);
        } else  {
            const auto cfg = KSharedConfig::openConfig()->group("Open File");
            dir = cfg.readEntry( "Last Open File Directory", Core::self()->projectController()->projectsBaseDirectory() );
        }
QUrl ProjectController::projectsBaseDirectory() const
{
    KConfigGroup group = ICore::self()->activeSession()->config()->group( "Project Manager" );
    return group.readEntry( "Projects Base Directory", QUrl::fromLocalFile( QDir::homePath() + "/projects" ) );
}

projectsBaseDirectory() doesn't look good... Have to get backtrace of Projects Toolview and try to figure out how to get dir of selected item from there.

midenok commented 6 years ago

File opened from project bar

ProjectTreeView::activate() -> ProjectManagerView::open()

#0  0x00007ffff03b6bf0 in __libc_open64 (file=file@entry=0x1998ef8 "/media/tmp/hello/CMakeLists.txt", oflag=oflag@entry=524288) at ../sysdeps/unix/sysv/linux/open64.c:29
#1  0x00007ffff119947c in open64 (__oflag=<optimized out>, __path=0x1998ef8 "/media/tmp/hello/CMakeLists.txt") at /usr/include/x86_64-linux-gnu/bits/fcntl2.h:91
#2  0x00007ffff119947c in qt_safe_open (mode=438, flags=<optimized out>, pathname=0x1998ef8 "/media/tmp/hello/CMakeLists.txt") at ../../include/QtCore/5.9.1/QtCore/private/../../../../../src/corelib/kernel/qcore_unix_p.h:184
#3  0x00007ffff119947c in QFSFileEnginePrivate::nativeOpen(QFlags<QIODevice::OpenModeFlag>) (this=this@entry=0x7fffcc013db0, openMode=..., openMode@entry=...) at io/qfsfileengine_unix.cpp:166
#4  0x00007ffff117a475 in QFSFileEngine::open(QFlags<QIODevice::OpenModeFlag>) (this=0x205f950, openMode=...) at io/qfsfileengine.cpp:219
#5  0x00007ffff1129137 in QFile::open(QFlags<QIODevice::OpenModeFlag>) (this=this@entry=0x7fffffff83a0, mode=..., mode@entry=...) at io/qfile.cpp:887
#6  0x00007ffff12923b5 in QMimeDatabase::mimeTypeForFile(QFileInfo const&, QMimeDatabase::MatchMode) const (this=this@entry=0x7fffffff8568, fileInfo=..., mode=mode@entry=QMimeDatabase::MatchDefault) at mimetypes/qmimedatabase.cpp:387
#7  0x00007ffff12927c6 in QMimeDatabase::mimeTypeForFile(QString const&, QMimeDatabase::MatchMode) const (this=this@entry=0x7fffffff8568, fileName="/media/tmp/hello/CMakeLists.txt", mode=mode@entry=QMimeDatabase::MatchDefault) at mimetypes/qmimedatabase.cpp:427
#8  0x00007ffff12928f1 in QMimeDatabase::mimeTypeForUrl(QUrl const&) const (this=0x7fffffff8568, url="/media/tmp/hello/CMakeLists.txt") at mimetypes/qmimedatabase.cpp:523
#9  0x00007fffab7a16a4 in OpenWithPlugin::openFilesInternal(QList<QUrl> const&) (this=0xf91c00, files=Python Exception <class 'TypeError'> unsupported operand type(s) for +: 'NoneType' and 'str': 
) at /home/midenok/src/kde/kdevelop/stable/kdevelop/plugins/openwith/openwithplugin.cpp:286
#10 0x00007fffb81c5b6c in KDevelop::IOpenWith::openFiles(QList<QUrl> const&) (files=Python Exception <class 'TypeError'> unsupported operand type(s) for +: 'NoneType' and 'str': 
) at /home/midenok/src/kde/kdevelop/stable/kdevelop/plugins/projectmanagerview/../openwith/iopenwith.h:51
#11 0x00007fffb81c33fe in ProjectManagerView::open(KDevelop::Path const&) (this=0x12a7750, path=("media", "tmp", "hello", "CMakeLists.txt")) at /home/midenok/src/kde/kdevelop/stable/kdevelop/plugins/projectmanagerview/projectmanagerview.cpp:273
#12 0x00007fffb81c7d79 in QtPrivate::FunctorCall<QtPrivate::IndexesList<0>, QtPrivate::List<KDevelop::Path const&>, void, void (ProjectManagerView::*)(KDevelop::Path const&)>::call(void (ProjectManagerView::*)(KDevelop::Path const&), ProjectManagerView*, void**) (f=(void (ProjectManagerView::*)(ProjectManagerView * const, const KDevelop::Path &)) 0x7fffb81c33c0 <ProjectManagerView::open(KDevelop::Path const&)>, o=0x12a7750, arg=0x7fffffff88e0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:136
#13 0x00007fffb81c7ce3 in QtPrivate::FunctionPointer<void (ProjectManagerView::*)(KDevelop::Path const&)>::call<QtPrivate::List<KDevelop::Path const&>, void>(void (ProjectManagerView::*)(KDevelop::Path const&), ProjectManagerView*, void**) (f=(void (ProjectManagerView::*)(ProjectManagerView * const, const KDevelop::Path &)) 0x7fffb81c33c0 <ProjectManagerView::open(KDevelop::Path const&)>, o=0x12a7750, arg=0x7fffffff88e0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:169
#14 0x00007fffb81c7c06 in QtPrivate::QSlotObject<void (ProjectManagerView::*)(KDevelop::Path const&), QtPrivate::List<KDevelop::Path const&>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0xec9ce0, r=0x12a7750, a=0x7fffffff88e0, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:120
#15 0x00007ffff123e9ff in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fffffff88e0, r=0x12a7750, this=0xec9ce0) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
#16 0x00007ffff123e9ff in QMetaObject::activate(QObject*, int, int, void**) (sender=0x12a8550, signalOffset=<optimized out>, local_signal_index=<optimized out>, argv=<optimized out>) at kernel/qobject.cpp:3749
#17 0x00007fffb81e162c in ProjectTreeView::activate(KDevelop::Path const&) (this=0x12a8550, _t1=("media", "tmp", "hello", "CMakeLists.txt")) at plugins/projectmanagerview/kdevprojectmanagerview_automoc.dir/moc_projecttreevie_QIPKDWS4PSNYAS.cpp:188
#18 0x00007fffb81ca5db in ProjectTreeView::slotActivated(QModelIndex const&) (this=0x12a8550, index=...) at /home/midenok/src/kde/kdevelop/stable/kdevelop/plugins/projectmanagerview/projecttreeview.cpp:291
midenok commented 6 years ago

Get path of project item

void ProjectTreeView::slotActivated( const QModelIndex &index )
{
    if ( QApplication::keyboardModifiers() & Qt::CTRL || QApplication::keyboardModifiers() & Qt::SHIFT ) {
        // Do not open file when Ctrl or Shift is pressed; that's for selection
        return;
    }
    KDevelop::ProjectBaseItem *item = index.data(ProjectModel::ProjectItemRole).value<ProjectBaseItem*>();
    if ( item && item->file() )
    {
        emit activate( item->file()->path() );
    }
}
midenok commented 6 years ago

Now we need to access ProjectTreeView from DocumentController(Private?).

It accessed like this: m_ui->projectTreeView:

    Ui::ProjectManagerView* m_ui;
ProjectManagerView::ProjectManagerView( ProjectManagerViewPlugin* plugin, QWidget *parent )
        : QWidget( parent ), m_ui(new Ui::ProjectManagerView), m_plugin(plugin)
./projectmanagerviewplugin.cpp:156:    core()->uiController()->addToolView( i18n("Projects"), d->factory );
midenok commented 6 years ago

"New file" in menu activated

#0  0x00007ffff7a4ac30 in KDevelop::TextDocument::TextDocument(QUrl const&, KDevelop::ICore*, QString const&) (this=0x20d2720, url="/Untitled", core=0x710e70, encoding="") at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/textdocument.cpp:253
#1  0x00007ffff7a5c8f4 in KDevelop::DocumentControllerPrivate::openDocumentInternal(QUrl const&, QString const&, KTextEditor::Range const&, QString const&, QFlags<KDevelop::IDocumentController::DocumentActivation>, KDevelop::IDocument*) (this=0xae81e0, inputUrl="/Untitled", prefName="", range=[(-1, -1) -> (-1, -1)], encoding="", activationParams=..., buddy=0x0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/documentcontroller.cpp:321
#2  0x00007ffff7a56cd6 in KDevelop::DocumentController::openDocument(QUrl const&, KTextEditor::Range const&, QFlags<KDevelop::IDocumentController::DocumentActivation>, QString const&, KDevelop::IDocument*) (this=0x9a0880, inputUrl="/Untitled", range=[(-1, -1) -> (-1, -1)], activationParams=..., encoding="", buddy=0x0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/documentcontroller.cpp:697
#3  0x00007ffff79f8ea6 in KDevelop::MainWindowPrivate::fileNew() (this=0x8b24d0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/mainwindow_actions.cpp:190
#4  0x00007ffff79fd3ae in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (KDevelop::MainWindowPrivate::*)()>::call(void (KDevelop::MainWindowPrivate::*)(), KDevelop::MainWindowPrivate*, void**) (f=(void (KDevelop::MainWindowPrivate::*)(KDevelop::MainWindowPrivate * const)) 0x7ffff79f8e30 <KDevelop::MainWindowPrivate::fileNew()>, o=0x8b24d0, arg=0x7fffffff8ce0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:136
#5  0x00007ffff79fd323 in QtPrivate::FunctionPointer<void (KDevelop::MainWindowPrivate::*)()>::call<QtPrivate::List<>, void>(void (KDevelop::MainWindowPrivate::*)(), KDevelop::MainWindowPrivate*, void**) (f=(void (KDevelop::MainWindowPrivate::*)(KDevelop::MainWindowPrivate * const)) 0x7ffff79f8e30 <KDevelop::MainWindowPrivate::fileNew()>, o=0x8b24d0, arg=0x7fffffff8ce0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobjectdefs_impl.h:169
#6  0x00007ffff79fd246 in QtPrivate::QSlotObject<void (KDevelop::MainWindowPrivate::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) (which=1, this_=0x8badf0, r=0x8b24d0, a=0x7fffffff8ce0, ret=0x0) at /usr/include/x86_64-linux-gnu/qt5/QtCore/qobject_impl.h:120
#7  0x00007ffff123e9ff in QtPrivate::QSlotObjectBase::call(QObject*, void**) (a=0x7fffffff8ce0, r=0x8b24d0, this=0x8badf0) at ../../include/QtCore/../../src/corelib/kernel/qobject_impl.h:101
#8  0x00007ffff123e9ff in QMetaObject::activate(QObject*, int, int, void**) (sender=sender@entry=0x8bac50, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff8ce0) at kernel/qobject.cpp:3749
#9  0x00007ffff123efb7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x8bac50, m=m@entry=0x7ffff264ade0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff8ce0) at kernel/qobject.cpp:3628
#10 0x00007ffff1f83d82 in QAction::triggered(bool) (this=this@entry=0x8bac50, _t1=<optimized out>) at .moc/moc_qaction.cpp:371
#11 0x00007ffff1f8646c in QAction::activate(QAction::ActionEvent) (this=0x8bac50, event=<optimized out>) at kernel/qaction.cpp:1159
#12 0x00007ffff20dee1c in QMenuPrivate::activateCausedStack(QVector<QPointer<QWidget> > const&, QAction*, QAction::ActionEvent, bool) (this=this@entry=0xe3e680, causedStack={...}, action=action@entry=0x8bac50, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1300
#13 0x00007ffff20e618b in QMenuPrivate::activateAction(QAction*, QAction::ActionEvent, bool) (this=this@entry=0xe3e680, action=action@entry=0x8bac50, action_e=action_e@entry=QAction::Trigger, self=self@entry=true) at widgets/qmenu.cpp:1377
#14 0x00007ffff20e6fd3 in QMenu::mouseReleaseEvent(QMouseEvent*) (this=<optimized out>, e=0x7fffffff92f0) at widgets/qmenu.cpp:2864
#15 0x00007ffff1fcadc8 in QWidget::event(QEvent*) (this=this@entry=0xe2a070, event=event@entry=0x7fffffff92f0) at kernel/qwidget.cpp:9178
#16 0x00007ffff20e91f3 in QMenu::event(QEvent*) (this=0xe2a070, e=0x7fffffff92f0) at widgets/qmenu.cpp:2986
#17 0x00007ffff1f8a46c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x665930, receiver=receiver@entry=0xe2a070, e=e@entry=0x7fffffff92f0) at kernel/qapplication.cpp:3717
#18 0x00007ffff1f9228f in QApplication::notify(QObject*, QEvent*) (this=<optimized out>, receiver=0xe2a070, e=0x7fffffff92f0) at kernel/qapplication.cpp:3193
#19 0x00007ffff120fde8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=receiver@entry=0xe2a070, event=event@entry=0x7fffffff92f0) at kernel/qcoreapplication.cpp:1018
#20 0x00007ffff1f91262 in QCoreApplication::sendEvent(QObject*, QEvent*) (event=<optimized out>, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:233
#21 0x00007ffff1f91262 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) (receiver=receiver@entry=0xe2a070, event=event@entry=0x7fffffff92f0, alienWidget=0x0, alienWidget@entry=0xe2a070, nativeWidget=0xe2a070, buttonDown=buttonDown@entry=0x7ffff26797c0 <qt_button_down>, lastMouseReceiver=..., spontaneous=true) at kernel/qapplication.cpp:2699
#22 0x00007ffff1fe5685 in QWidgetWindow::handleMouseEvent(QMouseEvent*) (this=this@entry=0x1335c50, event=event@entry=0x7fffffff96f0) at kernel/qwidgetwindow.cpp:516
#23 0x00007ffff1fe7fba in QWidgetWindow::event(QEvent*) (this=0x1335c50, event=0x7fffffff96f0) at kernel/qwidgetwindow.cpp:243
#24 0x00007ffff1f8a46c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x665930, receiver=receiver@entry=0x1335c50, e=e@entry=0x7fffffff96f0) at kernel/qapplication.cpp:3717
#25 0x00007ffff1f91d34 in QApplication::notify(QObject*, QEvent*) (this=0x7fffffffbae8, receiver=0x1335c50, e=0x7fffffff96f0) at kernel/qapplication.cpp:3476
#26 0x00007ffff120fde8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=receiver@entry=0x1335c50, event=event@entry=0x7fffffff96f0) at kernel/qcoreapplication.cpp:1018
#27 0x00007ffff17cef43 in QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) (event=0x7fffffff96f0, receiver=0x1335c50) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:236
#28 0x00007ffff17cef43 in QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) (e=0x7fff6401bc40) at kernel/qguiapplication.cpp:1949
#29 0x00007ffff17d0a25 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (e=e@entry=0x7fff6401bc40) at kernel/qguiapplication.cpp:1733
#30 0x00007ffff17a8cab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=...) at kernel/qwindowsysteminterface.cpp:939
#31 0x00007fffd4c2e5a0 in userEventSourceDispatch(GSource*, GSourceFunc, gpointer) (source=source@entry=0x69af90) at qeventdispatcher_glib.cpp:77
#32 0x00007fffe8298fb7 in g_main_dispatch (context=0x7fffcc004fc0) at ../../../../glib/gmain.c:3148
#33 0x00007fffe8298fb7 in g_main_context_dispatch (context=context@entry=0x7fffcc004fc0) at ../../../../glib/gmain.c:3813
#34 0x00007fffe82991f0 in g_main_context_iterate (context=context@entry=0x7fffcc004fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../../glib/gmain.c:3886
#35 0x00007fffe829927c in g_main_context_iteration (context=0x7fffcc004fc0, may_block=may_block@entry=1) at ../../../../glib/gmain.c:3947
#36 0x00007ffff126847f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x69a3a0, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#37 0x00007ffff120de3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffffff9aa0, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#38 0x00007ffff1216da4 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1291
#39 0x000000000040db91 in main(int, char**) (argc=3, argv=0x7fffffffbc58) at /home/midenok/src/kde/kdevelop/stable/kdevelop/app/main.cpp:784
(gdb) frame 3
#3  0x00007ffff79f8ea6 in KDevelop::MainWindowPrivate::fileNew (this=0x8b24d0) at /home/midenok/src/kde/kdevelop/stable/kdevelop/kdevplatform/shell/mainwindow_actions.cpp:190
190         Core::self()->documentControllerInternal()->openDocument(DocumentController::nextEmptyDocumentUrl());
(gdb) p DocumentController::nextEmptyDocumentUrl()
$20 = "/Untitled"
midenok commented 6 years ago
QUrl DocumentController::nextEmptyDocumentUrl()
{
    int nextEmptyDocNumber = 0;
    const auto& pattern = emptyDocumentPattern();
    foreach (IDocument *doc, Core::self()->documentControllerInternal()->openDocuments()) {
        if (DocumentController::isEmptyDocumentUrl(doc->url())) {
            const auto match = pattern.match(doc->url().toDisplayString(QUrl::PreferLocalFile));
            if (match.hasMatch()) {
                const int num = match.captured(1).toInt();
                nextEmptyDocNumber = qMax(nextEmptyDocNumber, num + 1);
            } else {
                nextEmptyDocNumber = qMax(nextEmptyDocNumber, 1);
            }
        }
    }

    QUrl url;
    if (nextEmptyDocNumber > 0)
        url = QUrl::fromLocalFile(QStringLiteral("/%1 (%2)").arg(EMPTY_DOCUMENT_URL).arg(nextEmptyDocNumber));
    else
        url = QUrl::fromLocalFile('/' + EMPTY_DOCUMENT_URL);
    return url;
}
midenok commented 6 years ago

Save file dialog also need to be adjusted.

midenok commented 6 years ago

From ToolView impossible to access ProjectManagerView or ProjectTreeView as it is simple QWidget.

midenok commented 6 years ago

As it seems impossible to access ProjectManagerView from anywhere else, should we react on signal?

void ProjectManagerView::selectionChanged()
{
    m_ui->buildSetView->selectionChanged();
    QList<ProjectBaseItem*> selected;
    foreach( const QModelIndex& idx, m_ui->projectTreeView->selectionModel()->selectedRows() )
    {
        selected << ICore::self()->projectController()->projectModel()->itemFromIndex(indexFromView( idx ));
    }
    selected.removeAll(nullptr);
    KDevelop::ICore::self()->selectionController()->updateSelection( new ProjectManagerViewItemContext( selected, this ) );
}
midenok commented 6 years ago

File save

Now goes out of KDevelop:

#0  0x00007ffff2181bb9 in QFileDialog::QFileDialog(QFileDialogArgs const&) (this=0x7fffffff9680, args=...) at dialogs/qfiledialog.cpp:368
#1  0x00007ffff2182682 in QFileDialog::getSaveFileUrl(QWidget*, QString const&, QUrl const&, QString const&, QString*, QFlags<QFileDialog::Option>, QStringList const&) (parent=0x9300f0, caption="Save File", dir="<empty>", filter="", selectedFilter=selectedFilter@entry=0x0, options=..., supportedSchemes=<empty>) at dialogs/qfiledialog.cpp:2411
#2  0x00007ffff650f28b in KTextEditor::DocumentPrivate::documentSaveAs() (this=0x1ebba70) at ./src/document/katedocument.cpp:4304
#3  0x00007ffff650c2b7 in KTextEditor::DocumentPrivate::documentSave() (this=0x1ebba70) at ./src/document/katedocument.cpp:4295
#4  0x00007ffff6697f13 in KTextEditor::DocumentPrivate::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) (_o=<optimized out>, _c=<optimized out>, _id=<optimized out>, _a=0x7fffffff9910) at ./obj-x86_64-linux-gnu/src/KF5TextEditor_autogen/DV7UALDUNI/moc_katedocument.cpp:512
#5  0x00007ffff123e8e5 in QMetaObject::activate(QObject*, int, int, void**) (sender=sender@entry=0x1172d90, signalOffset=<optimized out>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff9910) at kernel/qobject.cpp:3766
#6  0x00007ffff123efb7 in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) (sender=sender@entry=0x1172d90, m=m@entry=0x7ffff264ade0 <QAction::staticMetaObject>, local_signal_index=local_signal_index@entry=1, argv=argv@entry=0x7fffffff9910) at kernel/qobject.cpp:3628
#7  0x00007ffff1f83d82 in QAction::triggered(bool) (this=this@entry=0x1172d90, _t1=<optimized out>) at .moc/moc_qaction.cpp:371
#8  0x00007ffff1f8646c in QAction::activate(QAction::ActionEvent) (this=0x1172d90, event=<optimized out>) at kernel/qaction.cpp:1159
#9  0x00007ffff1f86d15 in QAction::event(QEvent*) (this=<optimized out>, e=<optimized out>) at kernel/qaction.cpp:1087
#10 0x00007ffff1f8a46c in QApplicationPrivate::notify_helper(QObject*, QEvent*) (this=this@entry=0x665930, receiver=receiver@entry=0x1172d90, e=e@entry=0x7fffffff9bc0) at kernel/qapplication.cpp:3717
#11 0x00007ffff1f91d34 in QApplication::notify(QObject*, QEvent*) (this=0x7fffffffc078, receiver=0x1172d90, e=0x7fffffff9bc0) at kernel/qapplication.cpp:3476
#12 0x00007ffff120fde8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) (receiver=0x1172d90, event=event@entry=0x7fffffff9bc0) at kernel/qcoreapplication.cpp:1018
#13 0x00007ffff17fcd77 in QCoreApplication::sendEvent(QObject*, QEvent*) (event=0x7fffffff9bc0, receiver=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:233
#14 0x00007ffff17fcd77 in QShortcutMap::dispatchEvent(QKeyEvent*) (this=this@entry=0x665a08, e=e@entry=0x7fffffff9c70) at kernel/qshortcutmap.cpp:674
#15 0x00007ffff17fce4a in QShortcutMap::tryShortcut(QKeyEvent*) (this=this@entry=0x665a08, e=e@entry=0x7fffffff9c70) at kernel/qshortcutmap.cpp:351
#16 0x00007ffff17ac473 in QWindowSystemInterface::handleShortcutEvent(QWindow*, unsigned long, int, QFlags<Qt::KeyboardModifier>, unsigned int, unsigned int, unsigned int, QString const&, bool, unsigned short) (window=<optimized out>, window@entry=0xc72590, timestamp=179983044, keyCode=83, modifiers=..., nativeScanCode=39, nativeVirtualKey=115, nativeModifiers=4, text="\023", autorepeat=false, count=1) at kernel/qwindowsysteminterface.cpp:375
#17 0x00007ffff17cb9b7 in QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent*) (e=0x7fffcc00a0f0) at kernel/qguiapplication.cpp:2056
#18 0x00007ffff17d0a05 in QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) (e=e@entry=0x7fffcc00a0f0) at kernel/qguiapplication.cpp:1739
#19 0x00007ffff17a8cab in QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) (flags=...) at kernel/qwindowsysteminterface.cpp:939
#20 0x00007fffd4c2e5a0 in userEventSourceDispatch(GSource*, GSourceFunc, gpointer) (source=source@entry=0x69b140) at qeventdispatcher_glib.cpp:77
#21 0x00007fffe8298fb7 in g_main_dispatch (context=0x7fffcc004fc0) at ../../../../glib/gmain.c:3148
#22 0x00007fffe8298fb7 in g_main_context_dispatch (context=context@entry=0x7fffcc004fc0) at ../../../../glib/gmain.c:3813
#23 0x00007fffe82991f0 in g_main_context_iterate (context=context@entry=0x7fffcc004fc0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../../../../glib/gmain.c:3886
#24 0x00007fffe829927c in g_main_context_iteration (context=0x7fffcc004fc0, may_block=may_block@entry=1) at ../../../../glib/gmain.c:3947
#25 0x00007ffff126847f in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x69a550, flags=...) at kernel/qeventdispatcher_glib.cpp:423
#26 0x00007ffff120de3a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffffffa030, flags=..., flags@entry=...) at kernel/qeventloop.cpp:212
#27 0x00007ffff1216da4 in QCoreApplication::exec() () at kernel/qcoreapplication.cpp:1291
#28 0x000000000040db91 in main(int, char**) (argc=3, argv=0x7fffffffc1e8) at /home/midenok/src/kde/kdevelop/stable/kdevelop/app/main.cpp:784
midenok commented 6 years ago

Postponed Save As fix as I don't know how to connect to KStandardAction::SaveAs.