diff --git a/debugger/interfaces/ivariablecontroller.cpp b/debugger/interfaces/ivariablecontroller.cpp index 6c007f1ae2..b15a50d811 100644 --- a/debugger/interfaces/ivariablecontroller.cpp +++ b/debugger/interfaces/ivariablecontroller.cpp @@ -1,120 +1,123 @@ /*************************************************************************** * This file is part of KDevelop * * Copyright 2009 Niko Sams * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include "ivariablecontroller.h" #include "idebugsession.h" #include "../../interfaces/icore.h" #include "../../interfaces/idebugcontroller.h" #include "../variable/variablecollection.h" #include "iframestackmodel.h" namespace KDevelop { IVariableController::IVariableController(IDebugSession* parent) : QObject(parent), m_activeThread(-1), m_activeFrame(-1) { connect(parent, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SLOT(stateChanged(KDevelop::IDebugSession::DebuggerState))); } VariableCollection* IVariableController::variableCollection() { + if (!ICore::self()) return 0; return ICore::self()->debugController()->variableCollection(); } IDebugSession* IVariableController::session() const { return static_cast(parent()); } void IVariableController::stateChanged(IDebugSession::DebuggerState state) { if (state == IDebugSession::ActiveState) { //variables are now outdated, update them m_activeThread = -1; m_activeFrame = -1; } else if (state == IDebugSession::EndedState || state == IDebugSession::NotStartedState) { // Remove all locals. foreach (Locals *l, variableCollection()->allLocals()) { l->deleteChildren(); l->setHasMore(false); } for (int i=0; i < variableCollection()->watches()->childCount(); ++i) { Variable *var = dynamic_cast(variableCollection()->watches()->child(i)); if (var) { var->setInScope(false); } } } } void IVariableController::updateIfFrameOrThreadChanged() { IFrameStackModel *sm = session()->frameStackModel(); if (sm->currentThread() != m_activeThread || sm->currentFrame() != m_activeFrame) { m_activeThread = sm->currentThread(); m_activeFrame = sm->currentFrame(); update(); } } void IVariableController::handleEvent(IDebugSession::event_t event) { + if (!variableCollection()) return; + switch (event) { case IDebugSession::program_state_changed: case IDebugSession::thread_or_frame_changed: kDebug() << m_autoUpdate; if (!(m_autoUpdate & UpdateLocals)) { foreach (Locals *l, variableCollection()->allLocals()) { if (!l->isExpanded() && !l->childCount()) { l->setHasMore(true); } } } if (m_autoUpdate != UpdateNone) { updateIfFrameOrThreadChanged(); } break; default: break; } } void IVariableController::setAutoUpdate(QFlags autoUpdate) { IDebugSession::DebuggerState state = session()->state(); m_autoUpdate = autoUpdate; if (m_autoUpdate != UpdateNone && state == IDebugSession::PausedState) { updateIfFrameOrThreadChanged(); } } QFlags IVariableController::autoUpdate() { return m_autoUpdate; } } #include "ivariablecontroller.moc" diff --git a/plugins/grepview/grepdialog.cpp b/plugins/grepview/grepdialog.cpp index ce69e25810..102907a230 100644 --- a/plugins/grepview/grepdialog.cpp +++ b/plugins/grepview/grepdialog.cpp @@ -1,291 +1,291 @@ /*************************************************************************** * Copyright 1999-2001 Bernd Gehrmann and the KDevelop Team * * bernd@kdevelop.org * * Copyright 2007 Dukju Ahn * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "grepdialog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "grepviewplugin.h" #include "grepjob.h" namespace { static int const MAX_LAST_SEARCH_ITEMS_COUNT = 15; const QStringList template_desc = QStringList() << "verbatim" << "assignment" << "->MEMBER(" << "class::MEMBER(" << "OBJECT->member("; const QStringList template_str = QStringList() << "%s" << "\\<%s\\>[\\t ]*=[^=]" << "\\->[\\t ]*\\<%s\\>[\\t ]*\\(" << "[a-z0-9_$]+[\\t ]*::[\\t ]*\\<%s\\>[\\t ]*\\(" << "\\<%s\\>[\\t ]*\\->[\\t ]*[a-z0-9_$]+[\\t ]*\\("; const QStringList filepatterns = QStringList() << "*.h,*.hxx,*.hpp,*.hh,*.h++,*.H,*.tlh,*.cpp,*.cc,*.C,*.c++,*.cxx,*.ocl,*.inl,*.idl,*.c,*.m,*.mm,*.M" << "*.cpp,*.cc,*.C,*.c++,*.cxx,*.ocl,*.inl,*.c,*.m,*.mm,*.M" << "*.h,*.hxx,*.hpp,*.hh,*.h++,*.H,*.tlh,*.idl" << "*.adb" << "*.cs" << "*.f" << "*.html,*.htm" << "*.hs" << "*.java" << "*.js" << "*.php,*.php3,*.php4" << "*.pl" << "*.pp,*.pas" << "*.py" << "*.js,*.css,*.yml,*.rb,*.rhtml,*.html.erb,*.rjs,*.js.rjs,*.rxml,*.xml.builder" << "CMakeLists.txt,*.cmake" << "*"; const QStringList excludepatterns = QStringList() - << "/CVS/,/SCCS/,/\\.svn/,/_darcs/,/build/,/.git/" + << "/CVS/,/SCCS/,/\\.svn/,/_darcs/,/build/,/\\.git/" << ""; } GrepDialog::GrepDialog( GrepViewPlugin * plugin, QWidget *parent ) : KDialog(parent), Ui::GrepWidget(), m_plugin( plugin ) { setAttribute(Qt::WA_DeleteOnClose); setButtons( KDialog::Ok | KDialog::Cancel ); setButtonText( KDialog::Ok, i18n("Search") ); setCaption( i18n("Find In Files") ); setDefaultButton( KDialog::Ok ); setupUi(mainWidget()); KConfigGroup cg = KGlobal::config()->group( "GrepDialog" ); patternCombo->addItem( "" ); patternCombo->addItems( cg.readEntry("LastSearchItems", QStringList()) ); patternCombo->setInsertPolicy(QComboBox::InsertAtTop); templateEdit->setText(template_str[0]); templateTypeCombo->addItems(template_desc); regexCheck->setChecked(cg.readEntry("regexp", false )); caseSensitiveCheck->setChecked(cg.readEntry("case_sens", true)); directoryRequester->setUrl( KUrl( QDir::homePath() ) ); directoryRequester->fileDialog()->setUrl( KUrl( QDir::homePath() ) ); directoryRequester->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly ); syncButton->setIcon(KIcon("dirsync")); recursiveCheck->setChecked(cg.readEntry("recursive", true)); limitToProjectCheck->setChecked(cg.readEntry("search_project_files", true)); filesCombo->addItems(cg.readEntry("file_patterns", filepatterns)); excludeCombo->addItems(cg.readEntry("exclude_patterns", excludepatterns) ); suppressErrorsCheck->setChecked(cg.readEntry("no_find_errs", true)); connect(this, SIGNAL(okClicked()), this, SLOT(search())); connect(syncButton, SIGNAL(clicked()), this, SLOT(syncButtonClicked())); connect(templateTypeCombo, SIGNAL(activated(int)), this, SLOT(templateTypeComboActivated(int))); connect(patternCombo, SIGNAL(editTextChanged(const QString&)), this, SLOT(patternComboEditTextChanged( const QString& ))); patternComboEditTextChanged( patternCombo->currentText() ); patternCombo->setFocus(); } // Returns the contents of a QComboBox as a QStringList static QStringList qCombo2StringList( QComboBox* combo ) { QStringList list; if (!combo) { return list; } int skippedItem = -1; if (!combo->currentText().isEmpty()) { list << combo->currentText(); } if (combo->currentIndex() != -1 && !combo->itemText(combo->currentIndex()).isEmpty()) { skippedItem = combo->currentIndex(); } for (int i = 0; i < std::min(MAX_LAST_SEARCH_ITEMS_COUNT, combo->count()); ++i) { if (i != skippedItem && !combo->itemText(i).isEmpty()) { list << combo->itemText(i); } } return list; } GrepDialog::~GrepDialog() { KConfigGroup cg = KGlobal::config()->group( "GrepDialog" ); // memorize the last patterns and paths cg.writeEntry("LastSearchItems", qCombo2StringList(patternCombo)); cg.writeEntry("regexp", regexCheck->isChecked()); cg.writeEntry("recursive", recursiveCheck->isChecked()); cg.writeEntry("search_project_files", limitToProjectCheck->isChecked()); cg.writeEntry("case_sens", caseSensitiveCheck->isChecked()); cg.writeEntry("no_find_errs", suppressErrorsCheck->isChecked()); cg.writeEntry("exclude_patterns", qCombo2StringList(excludeCombo)); cg.writeEntry("file_patterns", qCombo2StringList(filesCombo)); cg.sync(); } void GrepDialog::templateTypeComboActivated(int index) { templateEdit->setText(template_str[index]); } void GrepDialog::syncButtonClicked( ) { KDevelop::IDocument *doc = m_plugin->core()->documentController()->activeDocument(); kDebug(9001) << doc; if ( doc ) { KUrl url = doc->url(); if ( url.isLocalFile() ) { directoryRequester->lineEdit()->setText( url.upUrl().toLocalFile( KUrl::LeaveTrailingSlash ) ); } } } void GrepDialog::setEnableProjectBox(bool enable) { limitToProjectCheck->setEnabled(enable); if (!enable) limitToProjectCheck->setChecked(false); } void GrepDialog::setPattern(const QString &pattern) { patternCombo->setEditText(pattern); } void GrepDialog::setDirectory(const QString &dir) { directoryRequester->lineEdit()->setText(dir); directoryRequester->fileDialog()->setUrl( KUrl( dir ) ); directoryRequester->completionObject()->setDir( dir ); } QString GrepDialog::patternString() const { return patternCombo->currentText(); } QString GrepDialog::templateString() const { return templateEdit->text(); } QString GrepDialog::filesString() const { return filesCombo->currentText(); } QString GrepDialog::excludeString() const { return excludeCombo->currentText(); } KUrl GrepDialog::directory() const { return directoryRequester->url(); } bool GrepDialog::useProjectFilesFlag() const { return limitToProjectCheck->isChecked(); } bool GrepDialog::regexpFlag() const { return regexCheck->isChecked(); } bool GrepDialog::recursiveFlag() const { return recursiveCheck->isChecked(); } bool GrepDialog::noFindErrorsFlag() const { return suppressErrorsCheck->isChecked(); } bool GrepDialog::caseSensitiveFlag() const { return caseSensitiveCheck->isChecked(); } void GrepDialog::patternComboEditTextChanged( const QString& text) { enableButtonOk( !text.isEmpty() ); } void GrepDialog::search() { GrepJob* job = new GrepJob(); job->setPatternString(patternString()); job->templateString = templateString(); job->filesString = filesString(); job->excludeString = excludeString(); job->directory = directory(); job->useProjectFilesFlag = useProjectFilesFlag(); job->regexpFlag = regexpFlag(); job->recursiveFlag = recursiveFlag(); job->noFindErrorsFlag = noFindErrorsFlag(); job->caseSensitiveFlag = caseSensitiveFlag(); kDebug() << "registering job"; KDevelop::ICore::self()->runController()->registerJob(job); m_plugin->rememberSearchDirectory(directory().toLocalFile(KUrl::AddTrailingSlash)); close(); } #include "grepdialog.moc" diff --git a/shell/debugcontroller.cpp b/shell/debugcontroller.cpp index 50ca0785d6..f2ae480feb 100644 --- a/shell/debugcontroller.cpp +++ b/shell/debugcontroller.cpp @@ -1,517 +1,517 @@ /* This file is part of KDevelop * * Copyright 1999-2001 John Birch * Copyright 2001 by Bernd Gehrmann * Copyright 2006 Vladimir Prus * Copyright 2007 Hamish Rodda * Copyright 2009 Niko Sams * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ #include "debugcontroller.h" #include #include #include #include #include #include #include #include #include #include "../interfaces/idocument.h" #include "../interfaces/icore.h" #include "../interfaces/idocumentcontroller.h" #include "../interfaces/ipartcontroller.h" #include "../interfaces/contextmenuextension.h" #include "../interfaces/context.h" #include "../language/interfaces/editorcontext.h" #include "../sublime/view.h" #include "../sublime/mainwindow.h" #include "../sublime/area.h" #include "core.h" #include "uicontroller.h" #include "../debugger/breakpoint/breakpointmodel.h" #include "../debugger/breakpoint/breakpointwidget.h" #include "../debugger/variable/variablewidget.h" #include "../debugger/framestack/framestackmodel.h" #include "../debugger/framestack/framestackwidget.h" namespace KDevelop { template class DebuggerToolFactory : public KDevelop::IToolViewFactory { public: DebuggerToolFactory(DebugController* controller, const QString &id, Qt::DockWidgetArea defaultArea) : m_controller(controller), m_id(id), m_defaultArea(defaultArea) {} virtual QWidget* create(QWidget *parent = 0) { return new T(m_controller, parent); } virtual QString id() const { return m_id; } virtual Qt::DockWidgetArea defaultPosition() { return m_defaultArea; } virtual void viewCreated(Sublime::View* view) { if (view->widget()->metaObject()->indexOfSignal("requestRaise()") != -1) QObject::connect(view->widget(), SIGNAL(requestRaise()), view, SLOT(requestRaise())); } /* At present, some debugger widgets (e.g. breakpoint) contain actions so that shortcuts work, but they don't need any toolbar. So, suppress toolbar action. */ virtual QList toolBarActions( QWidget* viewWidget ) const { Q_UNUSED(viewWidget); return QList(); } private: DebugController* m_controller; QString m_id; Qt::DockWidgetArea m_defaultArea; }; DebugController::DebugController(QObject *parent) : IDebugController(parent), KXMLGUIClient(), m_breakpointModel(new BreakpointModel(this)), m_variableCollection(new VariableCollection(this)) { setComponentData(KComponentData("kdevdebugger")); setXMLFile("kdevdebuggershellui.rc"); if((Core::self()->setupFlags() & Core::NoUi)) return; setupActions(); ICore::self()->uiController()->addToolView( i18n("Frame Stack"), new DebuggerToolFactory( this, "org.kdevelop.debugger.StackView", Qt::BottomDockWidgetArea)); ICore::self()->uiController()->addToolView( i18n("Breakpoints"), new DebuggerToolFactory( this, "org.kdevelop.debugger.BreakpointsView", Qt::BottomDockWidgetArea)); ICore::self()->uiController()->addToolView( i18n("Variables"), new DebuggerToolFactory( this, "org.kdevelop.debugger.VariablesView", Qt::LeftDockWidgetArea)); foreach(KParts::Part* p, KDevelop::ICore::self()->partController()->parts()) partAdded(p); connect(KDevelop::ICore::self()->partController(), SIGNAL(partAdded(KParts::Part*)), this, SLOT(partAdded(KParts::Part*))); } void DebugController::initialize() { stateChanged("ended"); } void DebugController::cleanup() { if (m_currentSession) m_currentSession->stopDebugger(); } DebugController::~DebugController() { } BreakpointModel* DebugController::breakpointModel() { return m_breakpointModel; } VariableCollection* DebugController::variableCollection() { return m_variableCollection; } void DebugController::partAdded(KParts::Part* part) { if (KTextEditor::Document* doc = dynamic_cast(part)) { KTextEditor::MarkInterface *iface = dynamic_cast(doc); if( !iface ) return; iface->setMarkPixmap(KTextEditor::MarkInterface::Execution, *executionPointPixmap()); } } IDebugSession* DebugController::currentSession() { return m_currentSession; } void DebugController::setupActions() { KActionCollection* ac = actionCollection(); KAction* action = m_continueDebugger = new KAction(KIcon("media-playback-start"), i18n("&Continue"), this); action->setToolTip( i18n("Continues the application execution") ); action->setWhatsThis( i18n("Continue application execution

" "Continues the execution of your application in the " "debugger. This only takes effect when the application " "has been halted by the debugger (i.e. a breakpoint has " "been activated or the interrupt was pressed).

") ); ac->addAction("debug_continue", action); connect(action, SIGNAL(triggered(bool)), this, SLOT(run())); #if 0 m_restartDebugger = action = new KAction(KIcon("media-seek-backward"), i18n("&Restart"), this); action->setToolTip( i18n("Restart program") ); action->setWhatsThis( i18n("Restarts application

" "Restarts applications from the beginning.

" ) ); action->setEnabled(false); connect(action, SIGNAL(triggered(bool)), this, SLOT(restartDebugger())); ac->addAction("debug_restart", action); #endif m_interruptDebugger = action = new KAction(KIcon("media-playback-pause"), i18n("Interrupt"), this); action->setToolTip( i18n("Interrupt application") ); action->setWhatsThis(i18n("Interrupt application

Interrupts the debugged process or current debugger command.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(interruptDebugger())); ac->addAction("debug_pause", action); m_runToCursor = action = new KAction(KIcon("debug-run-cursor"), i18n("Run to &Cursor"), this); action->setToolTip( i18n("Run to cursor") ); action->setWhatsThis(i18n("Run to cursor

Continues execution until the cursor position is reached.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(runToCursor())); ac->addAction("debug_runtocursor", action); m_jumpToCursor = action = new KAction(KIcon("debug-execute-to-cursor"), i18n("Set E&xecution Position to Cursor"), this); action->setToolTip( i18n("Jump to cursor") ); action->setWhatsThis(i18n("Set Execution Position

Set the execution pointer to the current cursor position.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(jumpToCursor())); ac->addAction("debug_jumptocursor", action); m_stepOver = action = new KAction(KIcon("debug-step-over"), i18n("Step &Over"), this); action->setShortcut(Qt::Key_F10); action->setToolTip( i18n("Step over the next line") ); action->setWhatsThis( i18n("Step over

" "Executes one line of source in the current source file. " "If the source line is a call to a function the whole " "function is executed and the app will stop at the line " "following the function call.

") ); connect(action, SIGNAL(triggered(bool)), this, SLOT(stepOver())); ac->addAction("debug_stepover", action); m_stepOverInstruction = action = new KAction(KIcon("debug-step-instruction"), i18n("Step over Ins&truction"), this); action->setToolTip( i18n("Step over instruction") ); action->setWhatsThis(i18n("Step over instruction

Steps over the next assembly instruction.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(stepIntoInstruction())); ac->addAction("debug_stepoverinst", action); m_stepInto = action = new KAction(KIcon("debug-step-into"), i18n("Step &Into"), this); action->setShortcut(Qt::Key_F11); action->setToolTip( i18n("Step into the next statement") ); action->setWhatsThis( i18n("Step into

" "Executes exactly one line of source. If the source line " "is a call to a function then execution will stop after " "the function has been entered.

") ); connect(action, SIGNAL(triggered(bool)), this, SLOT(stepInto())); ac->addAction("debug_stepinto", action); m_stepIntoInstruction = action = new KAction(KIcon("debug-step-into-instruction"), i18n("Step into I&nstruction"), this); action->setToolTip( i18n("Step into instruction") ); action->setWhatsThis(i18n("Step into instruction

Steps into the next assembly instruction.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(stepOverInstruction())); ac->addAction("debug_stepintoinst", action); m_stepOut = action = new KAction(KIcon("debug-step-out"), i18n("Step O&ut"), this); action->setShortcut(Qt::Key_F12); action->setToolTip( i18n("Steps out of the current function") ); action->setWhatsThis( i18n("Step out

" "Executes the application until the currently executing " "function is completed. The debugger will then display " "the line after the original call to that function. If " "program execution is in the outermost frame (i.e. in " "main()) then this operation has no effect.

") ); connect(action, SIGNAL(triggered(bool)), this, SLOT(stepOut())); ac->addAction("debug_stepout", action); m_toggleBreakpoint = action = new KAction(i18n("Toggle Breakpoint"), this); action->setToolTip(i18n("Toggle breakpoint")); action->setWhatsThis(i18n("Toggle breakpoint

Toggles the breakpoint at the current line in editor.

")); connect(action, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpoint())); ac->addAction("debug_toggle_breakpoint", action); } void DebugController::addSession(IDebugSession* session) { kDebug() << session; Q_ASSERT(session->variableController()); Q_ASSERT(session->breakpointController()); Q_ASSERT(session->frameStackModel()); //TODO support multiple sessions if (m_currentSession) { m_currentSession->stopDebugger(); } m_currentSession = session; connect(session, SIGNAL(stateChanged(KDevelop::IDebugSession::DebuggerState)), SLOT(debuggerStateChanged(KDevelop::IDebugSession::DebuggerState))); connect(session, SIGNAL(showStepInSource(KUrl,int)), SLOT(showStepInSource(KUrl,int))); connect(session, SIGNAL(clearExecutionPoint()), SLOT(clearExecutionPoint())); connect(session, SIGNAL(raiseFramestackViews()), SIGNAL(raiseFramestackViews())); updateDebuggerState(session->state(), session); emit currentSessionChanged(session); if((Core::self()->setupFlags() & Core::NoUi)) return; Sublime::MainWindow* mainWindow = Core::self()->uiControllerInternal()->activeSublimeWindow(); if (mainWindow->area()->objectName() != "debug") { QString workingSet = mainWindow->area()->workingSet(); ICore::self()->uiController()->switchToArea("debug", IUiController::ThisWindow); mainWindow->area()->setWorkingSet(workingSet); } } void DebugController::clearExecutionPoint() { kDebug(); foreach (KDevelop::IDocument* document, KDevelop::ICore::self()->documentController()->openDocuments()) { KTextEditor::MarkInterface *iface = dynamic_cast(document->textDocument()); if (!iface) continue; QHashIterator it = iface->marks(); while (it.hasNext()) { KTextEditor::Mark* mark = it.next().value(); if( mark->type & KTextEditor::MarkInterface::Execution ) iface->removeMark( mark->line, KTextEditor::MarkInterface::Execution ); } } } void DebugController::showStepInSource(const KUrl &url, int lineNum) { if((Core::self()->setupFlags() & Core::NoUi)) return; clearExecutionPoint(); kDebug() << url << lineNum; Q_ASSERT(dynamic_cast(sender())); QPair openUrl = static_cast(sender())->convertToLocalUrl(qMakePair( url, lineNum )); KDevelop::IDocument* document = KDevelop::ICore::self() ->documentController() ->openDocument(openUrl.first, KTextEditor::Cursor(openUrl.second, 0)); if( !document ) return; KTextEditor::MarkInterface *iface = dynamic_cast(document->textDocument()); if( !iface ) return; document->textDocument()->blockSignals(true); iface->addMark( lineNum, KTextEditor::MarkInterface::Execution ); document->textDocument()->blockSignals(false); } void DebugController::debuggerStateChanged(KDevelop::IDebugSession::DebuggerState state) { Q_ASSERT(dynamic_cast(sender())); IDebugSession* session = static_cast(sender()); kDebug() << session << state << "current" << m_currentSession; if (session == m_currentSession) { updateDebuggerState(state, session); } if (state == IDebugSession::EndedState) { if (session == m_currentSession) { m_currentSession = 0; emit currentSessionChanged(0); Sublime::MainWindow* mainWindow = Core::self()->uiControllerInternal()->activeSublimeWindow(); if (mainWindow && mainWindow->area()->objectName() != "code") { QString workingSet = mainWindow->area()->workingSet(); ICore::self()->uiController()->switchToArea("code", IUiController::ThisWindow); mainWindow->area()->setWorkingSet(workingSet); } ICore::self()->uiController()->findToolView(i18n("Debug"), 0, IUiController::Raise); } session->deleteLater(); } } void DebugController::updateDebuggerState(IDebugSession::DebuggerState state, IDebugSession *session) { Q_UNUSED(session); if((Core::self()->setupFlags() & Core::NoUi)) return; kDebug() << state; switch (state) { case IDebugSession::StoppedState: case IDebugSession::NotStartedState: case IDebugSession::StoppingState: kDebug() << "new state: stopped"; stateChanged("stopped"); clearExecutionPoint(); //m_restartDebugger->setEnabled(session->restartAvaliable()); break; case IDebugSession::StartingState: case IDebugSession::PausedState: kDebug() << "new state: paused"; stateChanged("paused"); //m_restartDebugger->setEnabled(session->restartAvaliable()); break; case IDebugSession::ActiveState: kDebug() << "new state: active"; stateChanged("active"); //m_restartDebugger->setEnabled(false); clearExecutionPoint(); break; case IDebugSession::EndedState: kDebug() << "new state: ended"; stateChanged("ended"); clearExecutionPoint(); //m_restartDebugger->setEnabled(false); break; } - if (state == IDebugSession::PausedState) { + if (state == IDebugSession::PausedState && ICore::self()->uiController()->activeMainWindow()) { ICore::self()->uiController()->activeMainWindow()->activateWindow(); } } ContextMenuExtension DebugController::contextMenuExtension( Context* context ) { ContextMenuExtension menuExt; if( context->type() != Context::EditorContext ) return menuExt; KDevelop::EditorContext *econtext = dynamic_cast(context); if (!econtext) return menuExt; if (m_currentSession && m_currentSession->isRunning()) { menuExt.addAction( KDevelop::ContextMenuExtension::DebugGroup, m_runToCursor); } if (econtext->url().isLocalFile()) { menuExt.addAction( KDevelop::ContextMenuExtension::DebugGroup, m_toggleBreakpoint); } return menuExt; } #if 0 void DebugController::restartDebugger() { if (m_currentSession) { m_currentSession->restartDebugger(); } } #endif void DebugController::stopDebugger() { if (m_currentSession) { m_currentSession->stopDebugger(); } } void DebugController::interruptDebugger() { if (m_currentSession) { m_currentSession->interruptDebugger(); } } void DebugController::run() { if (m_currentSession) { m_currentSession->run(); } } void DebugController::runToCursor() { if (m_currentSession) { m_currentSession->runToCursor(); } } void DebugController::jumpToCursor() { if (m_currentSession) { m_currentSession->jumpToCursor(); } } void DebugController::stepOver() { if (m_currentSession) { m_currentSession->stepOver(); } } void DebugController::stepIntoInstruction() { if (m_currentSession) { m_currentSession->stepIntoInstruction(); } } void DebugController::stepInto() { if (m_currentSession) { m_currentSession->stepInto(); } } void DebugController::stepOverInstruction() { if (m_currentSession) { m_currentSession->stepOverInstruction(); } } void DebugController::stepOut() { if (m_currentSession) { m_currentSession->stepOut(); } } void DebugController::toggleBreakpoint() { if (KDevelop::IDocument* document = KDevelop::ICore::self()->documentController()->activeDocument()) { KTextEditor::Cursor cursor = document->cursorPosition(); if (!cursor.isValid()) return; breakpointModel()->toggleBreakpoint(document->url(), cursor); } } const QPixmap* DebugController::executionPointPixmap() { static QPixmap pixmap=KIcon("go-next").pixmap(QSize(22,22), QIcon::Normal, QIcon::Off); return &pixmap; } }