<div dir="ltr"><div>Hi,</div><div><br></div><div>Many people have noticed online for few years that:</div><div>#1 qscintilla requires the debug/release configurations to match between qscintilla and Qt, else you're getting the error "QWidget: Must construct a QApplication before a QWidget" during the construction of QsciScintilla.</div><div>#2 qscinitilla release + Qt release + debug user application was crashing in the qscintilla destructor.</div><div><br></div><div><br></div><div>So this forces people to use Qt debug in their debug application which has pretty bad performance impact. it works on small programs, but on bigger application, especially graphics applications, you don't want to suffer 100s of milliseconds each time the Qt layout changes.</div><div>So asking people to switch to Qt debug isn't a solution since Qt release works perfectly fine in a debug application.</div><div><br></div><div>I haven't investigate problem #2 yet, but it sounds like a common issue with using STL streams. STL streams in a DLL requires the app to use the same CRT, especially when the dll was built with a different version of visual or a different compiler patch. Maya plugins have suffered from that issue in the past.</div><div><br></div><div>I looked at problem #1.</div><div>I used qscintilla debug, user app debug and Qt release.</div><div><br></div><div>I got:</div><div><br></div><div>Error: QWidget: Must construct a QApplication before a QWidget</div><div><br></div><div>Callstack:<br></div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">    </span>Qt5Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Line 1673<span class="gmail-Apple-tab-span" style="white-space:pre">      </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Qt5Cored.dll!QMessageLogger::fatal(const char * msg, ...) Line 793<span class="gmail-Apple-tab-span" style="white-space:pre">    </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Qt5Widgetsd.dll!QWidgetPrivate::QWidgetPrivate(int version) Line 302<span class="gmail-Apple-tab-span" style="white-space:pre">  </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Qt5Widgetsd.dll!QFramePrivate::QFramePrivate() Line 61<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Qt5Widgetsd.dll!QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate() Line 174<span class="gmail-Apple-tab-span" style="white-space:pre">     </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Qt5Widgetsd.dll!QAbstractScrollArea::QAbstractScrollArea(QWidget * parent) Line 567<span class="gmail-Apple-tab-span" style="white-space:pre">   </span>C++</div><div>><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>qscintilla2d.dll!QsciScintillaBase::QsciScintillaBase(QWidget * parent) Line 87<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>C++</div><div> <span class="gmail-Apple-tab-span" style="white-space:pre">  </span>qscintilla2d.dll!QsciScintilla::QsciScintilla(QWidget * parent) Line 63<span class="gmail-Apple-tab-span" style="white-space:pre">       </span>C++</div><div><br></div><div><br></div><div>In the Qt source, the error "QWidget: Must construct a QApplication before a QWidget" is returned if qApp is NULL.</div><div>qApp is call to an instance() function which points to the </div><div>"static QCoreApplication *self;" in the Qt class QCoreApplication.<br></div><div><br></div><div>This should not be possible for this static to be NULL if the QApplication has been initialized.</div><div>It's true, as long as it's the same qApp we're talking about.</div><div>And as we can see in the callstack the NULL qApp is in QtCore5d.dll , the debug library, while I was supposedly using the release Qt dlls.</div><div><br></div><div>I checked the list of loaded modules and sure enough, there were 2 versions of Qt loaded:</div><div><div>List of modules loaded:<br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>qscintilla2d.dll<span class="gmail-Apple-tab-span" style="white-space:pre">      </span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Qt5Core.dll<span class="gmail-Apple-tab-span" style="white-space:pre">   </span></div><div><span style="white-space:pre">        </span>Qt5Cored.dll</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Qt5Gui.dll</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>Qt5Guid.dll</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>Qt5PrintSupportd.dll</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>Qt5Widgets.dll</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Qt5Widgetsd.dll</div></div></div><div><br></div><div>The qscintilla dll is probably implicitely linking with Qt debug dlls in debug. And that's the problem.</div><div><br></div><div>I think it would be nice to mention this potential issue in big characters on the main page in the windows section, as most users will use Qt release for their debug application.</div><div>I also think, the makefile should be changed with the addition of a new configuration which is qscintilla debug linked with qt release.</div><div>And that probably should be the default.</div><div><br></div><div>Thanks,</div><div>Cedric.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>