Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QtWebEnginePage initialization seems to disable CrtDbgReport'ing
Forum Updated to NodeBB v4.3 + New Features

QtWebEnginePage initialization seems to disable CrtDbgReport'ing

Scheduled Pinned Locked Moved Solved QtWebEngine
3 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erika
    wrote on 14 Dec 2016, 22:43 last edited by
    #1

    We use _CrtDbgReportW to help us pop up a window during asserting. However, we've recently started working with QtWebEngine, and noticed that as soon as you work with a QtWebEnginePage, it seems to disable _CrtDbgReportW.

    Is there something I'm doing wrong? It seems weird to set the command line argument "--disable-breakpad" however there's not much documentation on whether it should indeed be set. Any suggestions would be a big help:

    #include <QtWidgets\QMainWindow>
    #include <QtWidgets\QApplication>
    #include <QtWebEngineWidgets\QtWebEngineWidgets>
    #include <QtWidgets\QMenuBar>
    
    // custom assert mechanism
    bool MyAssert(
    	const char* const pSzExpr,		//expression
    	const char* szFile, const unsigned nLine, const char* szFunc
    )
    {
    	size_t len = 0;
    	std::wstring wsFile(strlen(szFile)+1, L'#');
    	mbstowcs_s(&len, &wsFile[0], wcslen(wsFile.c_str()), szFile, strlen(szFile) + 1);
    
    	std::wstring wsMsg(strlen(pSzExpr)+1, L'#');
    	mbstowcs_s(&len, &wsMsg[0], wcslen(wsMsg.c_str()), pSzExpr, strlen(pSzExpr) + 1);
    	return _CrtDbgReportW(_CRT_ASSERT, wsFile.c_str(), nLine, nullptr, wsMsg.c_str()) != 1;
    }
    
    #define ASSERT( EXPR ) (( !!(EXPR) || MyAssert((#EXPR),__FILE__,__LINE__,__FUNCTION__) ) || (_CrtDbgBreak(), 0) )
    
    // qtwebengine's chromium disables ASSERTing via _CrtDbgReportW inside process_startup_helper.cc::SetupCRT
    // by setting _CrtSetReportMode(_CRT_ASSERT, 0) when !command_line.HasSwitch(switches::kDisableBreakpad)
    // ie. command line argument "--disable-breakpad" needs to be _set_
    int main( int argc, char *argv[] )
    {
    	QApplication app( argc, argv );
    	QMainWindow* mainWin = new QMainWindow();
    	QWebEngineView* pView = new QWebEngineView(mainWin);
    
    	ASSERT(false && "Pre-WebEnginePage"); // asserts here (and anytime before)...
    	auto pPage = pView->page(); 
    	ASSERT(false && "Post-WebEnginePage"); // ... but does not assert here (or hereafter)
    
    	pPage->setUrl( QUrl("http://www.google.com") );
    
    	// setup rest of the application and basic menu controls
    	QMenu* pQFile = mainWin->menuBar()->addMenu( QIcon(), "&File" );
    	mainWin->addAction( pQFile->addAction( QIcon(), "&Quit", qApp, SLOT( quit() ), Qt::Key_Q ) );
    
    	mainWin->setCentralWidget( pView );
    	mainWin->resize( 1024, 750 );
    	mainWin->show();
    
    	auto result = app.exec();
    
    	// tidy up and quit
    	delete pView;
    	delete mainWin;
    
    	ASSERT(false && "Done"); // does not assert here either
    
    	return result;
    }
    
    1 Reply Last reply
    0
    • E Offline
      E Offline
      Erika
      wrote on 15 Dec 2016, 19:02 last edited by Erika
      #2

      Rather than re-directing to CrtDbgReport, I can simplify the problem even further, and fail to assert post-initialization by using the pre-existing "_ASSERT" macro:

      	QWebEngineView* pView = new QWebEngineView(mainWin);
      
      	_ASSERT(false && "Pre-WebEnginePage"); // asserts here (and anytime before)...
      	auto pPage = pView->page();
      	_ASSERT(false && L"Post-WebEnginePage"); // ... but does not assert here (or hereafter)
      
      	pPage->setUrl(QUrl("http://www.google.com"));
      

      Any comments would be appreciated. I have also filed a bug: https://bugreports.qt.io/browse/QTBUG-57634

      1 Reply Last reply
      0
      • E Offline
        E Offline
        Erika
        wrote on 16 Dec 2016, 23:22 last edited by
        #3

        Fun update for anyone interested, searching for "breakpad chromium" is much more informative than "disable-breakpad chromium." Apparently "breakpad" is a crash reporting tool used by chromium, which suppresses CRT's ASSERTs when it is active (which is by default).

        Pass in "--disable-breakpad" as a commandline argument in the main method (it is detected by the win32 ::GetCommandLineW call), or consider saving the crt report mode before the web engine page initializes, and then restore it immediately afterwards.

        1 Reply Last reply
        1

        1/3

        14 Dec 2016, 22:43

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved