Skip to content

Commit 86eda3d

Browse files
committed
help viewer: report errors and make it work from windows build directory
1 parent 9ca0354 commit 86eda3d

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/core/qgscontexthelp.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QTextStream>
2323

2424
#include "qgscontexthelp.h"
25+
#include "qgsmessagelog.h"
2526
#include "qgsapplication.h"
2627
#include "qgslogger.h"
2728

@@ -56,17 +57,32 @@ QProcess *QgsContextHelp::start()
5657
QgsDebugMsg( QString( "Help path is %1" ).arg( helpPath ) );
5758

5859
QProcess *process = new QProcess;
59-
process->start( helpPath );
6060

6161
// Delete this object if the process terminates
6262
connect( process, SIGNAL( finished( int, QProcess::ExitStatus ) ), SLOT( processExited() ) );
6363

6464
// Delete the process if the application quits
6565
connect( qApp, SIGNAL( aboutToQuit() ), process, SLOT( terminate() ) );
6666

67+
connect( process, SIGNAL( error( QProcess::ProcessError ) ), this, SLOT( error( QProcess::ProcessError ) ) );
68+
69+
#ifdef Q_OS_WIN
70+
if ( QgsApplication::isRunningFromBuildDir() )
71+
{
72+
process->setEnvironment( QStringList() << QString( "PATH=%1;%2" ).arg( getenv( "PATH" ) ).arg( QApplication::applicationDirPath() ) );
73+
}
74+
#endif
75+
76+
process->start( helpPath );
77+
6778
return process;
6879
}
6980

81+
void QgsContextHelp::error( QProcess::ProcessError error )
82+
{
83+
QgsMessageLog::logMessage( tr( "Error starting help viewer [%1]" ).arg( error ), tr( "Context help" ) );
84+
}
85+
7086
void QgsContextHelp::showContext( QString context )
7187
{
7288
init();

src/core/qgscontexthelp.h

+2-10
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,8 @@
2121

2222
#include <QObject>
2323
#include <QHash>
24+
#include <QProcess>
2425

25-
class QProcess;
26-
27-
#ifdef Q_OS_MACX
28-
#define QGSCONTEXTHELP_REUSE 1
29-
#endif
3026
/** \ingroup core
3127
* Provides a context based help browser for a dialog.
3228
*
@@ -35,11 +31,6 @@ class QProcess;
3531
* viewer using QProcess and ensures that only one viewer is open.
3632
* The viewer will be terminated if open when the main application quits.
3733
*
38-
* If the compile-time flag QGSCONTEXTHELP_REUSE is defined, the help viewer
39-
* will be reused if it is still open. If this flag is not set, the viewer
40-
* process will be terminated if open and restarted; this makes it the top
41-
* window for window managers such as Linux/GNOME which will make a window
42-
* active but not bring it to the top if raised programatically.
4334
*/
4435
class CORE_EXPORT QgsContextHelp : public QObject
4536
{
@@ -49,6 +40,7 @@ class CORE_EXPORT QgsContextHelp : public QObject
4940

5041
private slots:
5142
void processExited();
43+
void error( QProcess::ProcessError error );
5244

5345
private:
5446
//! Constructor

0 commit comments

Comments
 (0)