简体   繁体   English

“内部错误:在psymtab中读取pc 0x0,但在symtab中未读取。”尝试实现简单MVC时QT中出现错误

[英]“Internal error: pc 0x0 in read in psymtab, but not in symtab.” error in QT while trying to implement simple MVC

I'm trying to implement a simple MVC in QT. 我正在尝试在QT中实现一个简单的MVC。 The goal is to have a single rendering widget, a model, and a controller. 目标是拥有一个渲染小部件,一个模型和一个控制器。 The controller will be an abstract base class with a "render" method, so each controller knows how to draw its model given something to paint on. 该控制器将是带有“ render”方法的抽象基类,因此每个控制器都知道如何在要绘制的东西上绘制其模型。 I've built a very simple sample of what I'm trying to accomplish, but when debugging, the following error is displayed almost immediately: 我已经建立了一个非常简单的示例来说明我要完成的工作,但是在调试时,几乎立即显示以下错误:

Internal error: pc 0x0 in read in psymtab, but not in symtab. 内部错误:在psymtab中读取了pc 0x0,但在symtab中没有读取。

I've stripped away as much as I could to reproduce the error. 我已尽力减少重现该错误。 Although the code will run and exit with what's displayed below, attempting to create the RenderWidget will lead to several errors, including a Segmentation Fault crash (in debug mode). 尽管代码将运行并退出,并显示以下内容,但是尝试创建RenderWidget会导致一些错误,包括分段错误崩溃(在调试模式下)。

Any help would be appreciated. 任何帮助,将不胜感激。 I've included the minimum code required to reproduce this error below. 我在下面提供了重现此错误所需的最少代码。 This was made in an empty QT Widget project without forms. 这是在没有表格的空QT Widget项目中完成的。

Update 1 更新1

I've spent some more time fighting with this error and I've narrowed it down further. 我花了更多时间来解决这个错误,并进一步缩小了范围。 I've trimmed the code down even further and moved it all into a single Main.cpp file, as per Mitch's suggestion. 根据Mitch的建议,我将代码进行了进一步的缩减,并将其全部移动到一个Main.cpp文件中。 The error appears if you place a breakpoint in the Main method and step into the MainWindow constructor. 如果在Main方法中放置一个断点并进入MainWindow构造函数,则会出现错误。

Main.cpp Main.cpp的

#include <QApplication>
#include <QWidget>
#include <QMainWindow>

class RenderWidget : public QWidget
{
    Q_OBJECT
public:
    explicit RenderWidget(QWidget *parent = 0);
};

RenderWidget::RenderWidget(QWidget *parent) :
    QWidget(parent)
{
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

private:
    RenderWidget* m_renderArea;
};

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    m_renderArea = new RenderWidget(this);
}

MainWindow::~MainWindow()
{

}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}

#include "main.moc"

It looks like the issue was either a bug with the version of QT I had installed, or with the debugger I was using. 看来问题出在我安装的QT版本或我正在使用的调试器上。 The problem was present even if I created a new project. 即使我创建了一个新项目,该问题仍然存在。 After installing QT 5.3 and getting the newest version of Debugging Tools for Windows, the error appears to be gone. 安装QT 5.3并获取Windows调试工具的最新版本后,该错误似乎消失了。

You should remove or implement your constructor in Controller: 您应该在Controller中删除或实现您的构造函数:

//Controller();

or 要么

Controller() {}

Moreover, in ControllerA , you should also call base class: 此外,在ControllerA ,您还应该调用基类:

ControllerA::ControllerA()
   : Controller()
{
}

Finally, ui_renderArea is not initialized. 最后, ui_renderArea未初始化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C++ QT 异常代码 0xc0000005 读取访问冲突在:0x0,标志=0x0 - C++ QT Exception code 0xc0000005 read access violation at: 0x0, flags=0x0 Qt5Cored!Qobject :: disconnect…在0x0处读取访问冲突 - Qt5Cored!Qobject::disconnect… read access violation at 0x0 线程 1:使用 scanf 时出现 EXC_BAD_ACCESS (code=1, address=0x0) 错误 - Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) error while using scanf 尝试使用向量实现堆栈时出错 - Error While Trying to Use Vector to Implement Stack 尝试删除QTextEdit中的单词时出现简单错误 - Qt simple error when trying to delete a word in QTextEdit 错误:线程 0x4c0c 以代码 0 (0x0) 退出。 抛出异常:读取访问冲突。 **this** 是 nullptr - ERROR :The thread 0x4c0c has exited with code 0 (0x0). Exception thrown: read access violation. **this** was nullptr qt:编译器中发生内部错误 - qt: an internal error occurced in the compiler 线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x0)错误 - Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) error 获取外部耳机 (8):当我尝试使用 maximilian 时出现 EXC_BAD_ACCESS (code=1, address=0x0) 错误 - Getting External Headphones (8): EXC_BAD_ACCESS (code=1, address=0x0) error when I am trying to use maximilian Qt UDP读取错误 - Qt UDP read error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM