QPixmap()的std :: bad_alloc问题

时间:2018-08-22 21:45:46

标签: c++ qt

我正在尝试构建我们的GUI项目之一。此版本适用于办公室中的每台计算机,除了两台新计算机。这是错误的终端输出:

viewPriorityChanged( 11, 0 )
viewPriorityChanged( 12, 0 )
viewPriorityChanged( 13, 0 )
MainWindow.cpp debug print #5
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
./runlp_common: line 320: 11123 Aborted  (core dumped) $3

如您所见,我已经在带有print语句的代码中进行了追溯。这是代码中错误的方法:

void MainWindow::updateDecoration()
{
  Geometry::DisplayTypes closest = Geometry::closestDisplayType();
  QString closestStr = Geometry::displayTypeString(closest).toLower();
  QString iconPath  = QString(QLatin1String(":/images/device_skin_%1.png")).
                              arg(closestStr);

  Messages::conout() << "MainWindow.cpp debug print #5" << std::endl;

  m_device = QPixmap(iconPath); <-- not making it past here

  Messages::conout() << "MainWindow.cpp debug print #6" << std::endl;

  QBitmap clBitmap = m_device.createHeuristicMask();
  setFixedSize(m_device.size());
  setMask(clBitmap);
  update();
}

(在我看来)最奇怪的是,这条线只会引起一些机器故障。任何想法可能在这里发生什么事情?

编辑:

我想更详细地描述终端输出:

MainWindow.cpp debug print #1
MainWindow.cpp debug print #2
ToolsViewConfigTip_Series: Preloading tip images
ToolsViewConfigTip_Capacity: Preloading tip images.
ln: cannot remove '/etc/localtime': Permission denied
Using QGLBridge
Using QGLBridge
QThread::start: Thread creation error: Resource temporarily unavailable
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
libpng error: Read Error
QImage::scaled: Image is a null image
viewPriorityChanged( 0, 0 )
viewPriorityChanged( 1, 0 )
viewPriorityChanged( 2, 0 )
viewPriorityChanged( 3, 0 )
viewPriorityChanged( 4, 0 )
viewPriorityChanged( 5, 0 )
viewPriorityChanged( 6, 0 )
viewPriorityChanged( 7, 0 )
viewPriorityChanged( 10, 0 )
viewPriorityChanged( 11, 0 )
viewPriorityChanged( 12, 0 )
viewPriorityChanged( 13, 0 )
MainWindow.cpp debug print #4
MainWindow.cpp debug print #5
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
./runlp_common: line 320: 22676 Aborted                 (core dumped) $3
----------- KillAllApps -----------
IsobusMuxServer::clientDisconnected() Client 1 is now disconnected and destroyed
IsobusMuxServer::clientDisconnected() Client 0 is now disconnected and destroyed
-----------------------------------

我在评论中采纳了有关使用valgrind的建议。在程序中,在此之前,实际上并没有alllocs,frees和字节分配。我尝试在valgrind软件包中运行其他各种工具,但没有任何运气。我遇到的唯一其他错误是在运行helgrind时:

ProprietarySocketServer::startServer() bind: Address already in use
ProprietarySocketServer::startServer() Could not bind on port 41263

0 个答案:

没有答案