使用Texlipse和Miktex 2.9的NullPointerException

时间:2011-02-24 10:13:06

标签: latex miktex

在我的Windows机器上将Miklipse与Miktex 2.9一起使用时,每次编译文档时系统都会抛出NullPointerExcpetion。

使用更新管理器更新Miktex 2.9发行版后问题消失了。希望这可以帮助那些遇到同样问题的人。

此致 Pwndrian

1 个答案:

答案 0 :(得分:2)

对我来说也是如此。

这是我所做的解决方法,但我认为这不是最佳解决方案。 我看到有一个错误被打开http://sourceforge.net/tracker/?func=detail&aid=3306779&group_id=133306&atid=726818

有一个班级net.sourceforge.texlipse.builder.TExlipseBuilder,我做了以下修改来克服这个问题(请注意两个函数的不同之处)。问题是在函数getCurrentProject中的TExlipsePlugin中,actEditor为null,因为导入项目时没有活动编辑器,或者在没有编辑器打开时按下clean。

@Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
        throws CoreException {      
    BuilderRegistry.clearConsole();
    IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
    IEditorPart actEditor = null;
    if (page.isEditorAreaVisible()
         && page.getActiveEditor() != null) {
        actEditor = page.getActiveEditor();
    }
    if ( actEditor == null )
        return null;

    if (isUpToDate(getProject()))
        return null;

    Object s = TexlipseProperties.getProjectProperty(getProject(), TexlipseProperties.PARTIAL_BUILD_PROPERTY);
    if (s != null) {
        partialBuild(monitor);
    } else {
        buildFile(null, monitor);
    }

    return null;
}

/**
 * Clean the temporary files.
 * 
 * @see IncrementalProjectBuilder.clean
 */
@Override
protected void clean(IProgressMonitor monitor) throws CoreException {
    IProject project = getProject();
    BuilderRegistry.clearConsole();
    IWorkbenchPage page = TexlipsePlugin.getCurrentWorkbenchPage();
    IEditorPart actEditor = null;
    if (page.isEditorAreaVisible()
         && page.getActiveEditor() != null) {
        actEditor = page.getActiveEditor();
    }
    if ( actEditor == null )
        return;        

    // reset session variables
    TexlipseProperties.setSessionProperty(project, TexlipseProperties.SESSION_LATEX_RERUN, null);
    TexlipseProperties.setSessionProperty(project, TexlipseProperties.SESSION_BIBTEX_RERUN, null);
    TexlipseProperties.setSessionProperty(project, TexlipseProperties.BIBFILES_CHANGED, null);

    // check main file
    String mainFile = TexlipseProperties.getProjectProperty(project, TexlipseProperties.MAINFILE_PROPERTY);
    if (mainFile == null || mainFile.length() == 0) {
        // main tex file not set -> nothing builded -> nothing to clean
        return;
        }

    cleanTempDir(monitor, project);
    cleanOutput(monitor, project);

    monitor.subTask(TexlipsePlugin.getResourceString("builderSubTaskCleanMarkers"));

    this.deleteMarkers(project);
    project.refreshLocal(IProject.DEPTH_INFINITE, monitor);
    monitor.done();
}