Uploaded image for project: 'Qt Mobility'
  1. Qt Mobility
  2. QTMOBILITY-2008

QSystemBatteryInfo crashes when the power adapter is plugged/unplugged

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 1.2.2
    • 1.2.0
    • System Information
    • None
    • Windows 7, 32 bits with Visual Studio 2010. qt 4.7.' and Qt mobilility 1.2, both compiled from sources
    • 570816df23c29f39a9983130c773b87e3560e1c9

    Description

      I have used the following code:
      QCoreApplication a(argc, argv);

      QSystemBatteryInfo *bi = new QSystemBatteryInfo();
      qDebug() << "battery status: " << bi->remainingCapacityPercent() << "%";
      return a.exec();

      Start the application on a laptop, then, while the application is still running, plug or unplug the power adapter. The application crashes and the crash occurs in systeminfo\qsysteminfo_win.cpp:1744

      #if !defined(Q_OS_WINCE)
      bool qax_winEventFilter(void *message)
      {
      MSG pMsg = (MSG)message;
      if( pMsg->message == WM_POWERBROADCAST) {

      qDebug() << Q_FUNC_INFO;
      POWERBROADCAST_SETTING* pps = (POWERBROADCAST_SETTING*) pMsg->lParam;
      if ( sizeof(int) == pps->DataLength &&
      pps->PowerSetting == GUID_BATTERY_PERCENTAGE_REMAINING ) {
      int nPercentLeft = (int)(DWORD_PTR) pps->Data;

      It seems that the event WM_POWERBROADCAST is send, but pMsg->lParam is NULL and the code does not handle this situation. Please see the attachment for a patch.

      Attachments

        Activity

          People

            jukukkon Juha Kukkonen
            cristeab Bogdan Cristea
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: