GUI: Show error if no default editor configured.

There always should be default editor if there is editor
application configured. But it is possible in some cases that
default application is "lost". So check that we have default
application configured before trying to use it. And inform user
to configure default application instead of silently failing to
open the application (and the file) for the user.
This commit is contained in:
Kimmo Varis 2011-07-17 15:11:24 +03:00
parent 79385f0ff8
commit aff8fbc05f
1 changed files with 16 additions and 2 deletions

View File

@ -681,9 +681,10 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
//If there are no applications specified, tell the user about it
if (mApplications->GetApplicationCount() == 0)
{
QMessageBox msg(QMessageBox::Information,
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("Configure the text file viewer program in Cppcheck preferences/Applications."),
tr("No editor application configured.\n\n"
"Configure the editor application for Cppcheck in preferences/Applications."),
QMessageBox::Ok,
this);
msg.exec();
@ -693,6 +694,19 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
if (application == -1)
application = mApplications->GetDefaultApplication();
if (application == -1)
{
QMessageBox msg(QMessageBox::Critical,
tr("Cppcheck"),
tr("No default editor application selected.\n\n"
"Please select the default editor application in preferences/Applications."),
QMessageBox::Ok,
this);
msg.exec();
return;
}
if (target && application >= 0 && application < mApplications->GetApplicationCount() && target->parent())
{
// Make sure we are working with the first column