Weird problem with setupUI call
I’m having some trouble getting a library to run using qwt, qt, and mingw on Windows 7. I can build and install the package without error. However, when I run the code, I can make it to
- ui->setupUI(this);
when it dies. I should point out that what I’m doing is creating a GUI for R (http:www.r-project.org) so the library is called from R and the error I’m getting is that R is shutdown with the message:
- This application has requested the Runtime to terminate it in an unusual way.
- Please contact the application's support team for more information.
- ERROR: loading failed
Anyone ever have trouble like this in their own applications before? I’m stumped as the call to ui->setupUI(this); seems so basic that there should not be any way for it to go wrong…
Thanks!!
Dave H
15 replies
OK. I was trying to save on the length of code…
Here is most of the constructor (I get an error that it is greater than 6000 characters trying to post the whole thing). The printf after the call to ui->setupUi(this); does not print. The code works on Linux…
- #if defined( __MINGW32__ )
- {
- printf("Can we make it here...n");
- ui->setupUi(this);
- #else
- ui(new Ui::gsDesign)
- {
- ui->setupUi(this);
- #endif
- printf("Maybe here...n");
- // install event filters
- ui->dnNameCombo->installEventFilter(this);
- printf("Now, maybe here...n");
- ui->dnDescCombo->installEventFilter(this);
- ...
- ui->eptErrorHSlider->setScalePosition( QwtSlider::BottomScale );
- ui->eptErrorHSlider->setRange( 0.0 , 100.0 , 0.1 );
- ui->eptPowerHSlider->setScalePosition( QwtSlider::BottomScale );
- ui->eptPowerHSlider->setRange( 0.0 , 100.0 , 0.5 );
- ui->eptErrorHSlider->setValue( ui->eptErrorDSpin->value() );
- ui->eptPowerHSlider->setValue( ui->eptPowerDSpin->value() );
- }
Mingw does not like the call to QMainWindow(parent), but it is apparently needed on the version of Qt I have installed on Linux. That’s the only reason.
I have tried running this through gdb, but have had some trouble as my version of R on windows was not built with the debug flags set. I should rebuild it with those flags set, but have not as of yet…
Mingw does not like the call to QMainWindow(parent)
This is definitely not true. This should work on all platforms as well as here.
Of the ui->setupUI(this) crash, the ui is propably not initialised. This you should see in your debugger.
I’m always use ui on all platforms (mac, unix, linux, windows mingw and windows msvc) and everything is working without platform definitions!
Here’s what I know. If I use the constructor specified in the else clause of the #if defined statement, I do not even enter the constructor function. If I use the one specified in the if (MINGW32) part, I do enter the constructor function. So, on my system, mingw does not seem to like the call to QMainWindow(parent).
If setupUi does not initialize the ui, then what does? Here’s the code that calls the constructor:
- void Init(int argc, char *argv[])
- {
- if (m_pgsdApp == NULL)
- {
- m_pSplash->show();
- int delay = 3500;
- m_pgsdApp->processEvents();
- m_gsdWindow = new gsDesign();
- }
- }
Sure!
- namespace Ui {
- class gsDesign;
- }
- Q_OBJECT
- public:
- ~gsDesign();
- enum Spending { LowerSpending, UpperSpending };
- enum MapAction { setMap, getMap };
- protected:
- private slots:
- void populatePlotFromDesignQMap();
- void fillAnalysisTable(double *array, int len);
- bool validatePiecewiseTables();
- double convertEventRate(double val);
- void dnDescCombo_returnPressed();
- void dnNameCombo_returnPressed();
- void on_menuActionAutoscalePlot_toggled(bool );
- void quit();
- void on_menuActionExit_triggered();
- void on_opYLabelLeftLine_editingFinished();
- void on_opXLabelLine_editingFinished();
- void on_opTitleLine_editingFinished();
- void on_opPlotRenderCombo_currentIndexChanged(int index);
- void on_menuActionPlotDefaults_triggered();
- bool exportAllDesigns();
- void on_menuActionExportAllDesigns_triggered();
- void on_toolbarActionSetWorkingDirectory_triggered();
- bool setWorkingDirectory();
- void on_menuActionChangeWorkingDirectory_triggered();
- void on_toolbarActionEditPlot_triggered();
- void on_menuActionExportPlot_triggered();
- void exportPlot();
- void on_toolbarActionExportPlot_triggered();
- bool exportDesign();
- bool save();
- bool saveAs();
- void about();
- void addNewDesign();
- void contextHelp();
- void deleteDesign();
- ...
- // QList of QMaps comprising design list
- // File I/O
- QString currentDesignFile;
- QString plotFilePath;
- QDir currentWorkingDirectory;
- };
Gerolf:
I reimplemented the constructor to look like what you posted. I also changed some slot/signal connectors based on trying to build this on a Mac (there were some on_xxx_valueChanged functions created and similar slot/signal connections defined in the .ui file. Linux did not warn and compiled and ran fine. Mac complained, but compiled and ran fine. Windows did not complain and compiled, but did not execute). When I made the change of removing the connections from the .ui file, I could then enter the constructor with the implementation you describe. I still cannot get past the call to setupUi.
Now, what would renaming the class get me?
Dave H
Here is the compilation and an example run. I decorated the code with some printf’s to show what is being called when. I do not understand the problem with QApplication as it was created many lines before the error shows up…
Compilation messages:
- dnadave@ecthgow-vm /c/Users/dnadave/workspace/GSDesignGUI/trunk/package
- $ R CMD INSTALL --no-clean-on-error gsDesignExplorer
- * installing to library 'c:/Program Files/R/R-2.13.0/library'
- * installing *source* package 'gsDesignExplorer' ...
- ** libs
- running src/Makefile.win ...
- mkdir -p ../explorergui-build;
- cd ../explorergui-build;
- CC="c:/rtools/mingw/bin/gcc.exe" CXX="c:/rtools/mingw/bin/g++.exe"
- cmake -G "MSYS Makefiles" ../src -DR_LIBRARIES="-Lc:/PROGRA~1/R/R-213~1.
- 0/bin/i386 -lR -L../inst/libs/i386"
- -DR_INCLUDES=c:/PROGRA~1/R/R-213~1.0/include -DCMAKE_INSTALL_PREFIX=../i
- nst/libs/i386/;
- make install;
- cp ../inst/libs/i386/bin/*.dll ../inst/libs/i386;
- rm -rf ../inst/libs/i386/bin;
- cp -Ru ../src/images/ ../inst
- -- The C compiler identification is GNU
- -- The CXX compiler identification is GNU
- -- Check for working C compiler: c:/Rtools/MinGW/bin/gcc.exe
- -- Check for working C compiler: c:/Rtools/MinGW/bin/gcc.exe -- works
- -- Detecting C compiler ABI info
- -- Detecting C compiler ABI info - done
- -- Check for working CXX compiler: c:/Rtools/MinGW/bin/g++.exe
- -- Check for working CXX compiler: c:/Rtools/MinGW/bin/g++.exe -- works
- -- Detecting CXX compiler ABI info
- -- Detecting CXX compiler ABI info - done
- -- Looking for Q_WS_X11
- -- Looking for Q_WS_X11 - not found.
- -- Looking for Q_WS_WIN
- -- Looking for Q_WS_WIN - found
- -- Looking for Q_WS_QWS
- -- Looking for Q_WS_QWS - not found.
- -- Looking for Q_WS_MAC
- -- Looking for Q_WS_MAC - not found.
- -- Found Qt-Version 4.7.3 (using c:/QtSDK/Desktop/Qt/4.7.3/mingw/bin/qmake.exe)
- -- Found Qwt: C:/Users/dnadave/workspace/GSDesignGUI/trunk/package/gsDesignExplo
- rer/inst/libs/i386/qwtd5.dll
- -- Configuring done
- -- Generating done
- -- Build files have been written to: C:/Users/dnadave/workspace/GSDesignGUI/trun
- k/package/gsDesignExplorer/explorergui-build
- [ 8%] Generating ui_gsdesign.h
- [ 16%] Building CXX object CMakeFiles/gsDesignExplorer.dir/Rcpp.cpp.obj
- [ 25%] Building CXX object CMakeFiles/gsDesignExplorer.dir/gsdesign.cpp.obj
- [ 33%] Building CXX object CMakeFiles/gsDesignExplorer.dir/gsDesignGUI.cpp.obj
- [ 41%] Building CXX object CMakeFiles/gsDesignExplorer.dir/gsDesignTips.cpp.obj
- [ 50%] Building CXX object CMakeFiles/gsDesignExplorer.dir/GsRList.cpp.obj
- [ 58%] Building CXX object CMakeFiles/gsDesignExplorer.dir/main.cpp.obj
- c:/Users/dnadave/workspace/GSDesignGUI/trunk/package/gsDesignExplorer/src/main.c
- pp:165:37: warning: unused parameter 'hModule'
- c:/Users/dnadave/workspace/GSDesignGUI/trunk/package/gsDesignExplorer/src/main.c
- pp:165:37: warning: unused parameter 'lpReserved'
- [ 66%] Generating gsDesignExplorer.def
- [ 75%] Generating moc_gsdesign.cxx
- [ 83%] Generating qrc_images.cxx
- Scanning dependencies of target gsDesignExplorer
- [ 91%] Building CXX object CMakeFiles/gsDesignExplorer.dir/moc_gsdesign.cxx.obj
- [100%] Building CXX object CMakeFiles/gsDesignExplorer.dir/qrc_images.cxx.obj
- Linking CXX shared library libgsDesignExplorer.dll
- Creating library file: libgsDesignExplorer.dll.a
- [100%] Built target gsDesignExplorer
- Install the project...
- -- Install configuration: ""
- -- Installing: C:/Users/dnadave/workspace/GSDesignGUI/trunk/package/gsDesignExpl
- orer/inst/libs/i386/./libgsDesignExplorer.dll
Example run:
- dnadave@ecthgow-vm ~
- $ R
- R version 2.13.0 (2011-04-13)
- Copyright (C) 2011 The R Foundation for Statistical Computing
- ISBN 3-900051-07-0
- Platform: i386-pc-mingw32/i386 (32-bit)
- R is free software and comes with ABSOLUTELY NO WARRANTY.
- You are welcome to redistribute it under certain conditions.
- Type 'license()' or 'licence()' for distribution details.
- Natural language support but running in an English locale
- R is a collaborative project with many contributors.
- Type 'contributors()' for more information and
- 'citation()' on how to cite R or R packages in publications.
- Type 'demo()' for some demos, 'help()' for on-line help, or
- 'help.start()' for an HTML browser interface to help.
- Type 'q()' to quit R.
- > library(gsDesignExplorer)
- Loading required package: gsDesign
- Loading required package: ggplot2
- Loading required package: reshape
- Loading required package: plyr
- Attaching package: 'reshape'
- The following object(s) are masked from 'package:plyr':
- rename, round_any
- Loading required package: grid
- Loading required package: proto
- Loading required package: xtable
- GsdState constructor called!
- In DllMain
- > gsDesignExplorer()
- In GsdStartup
- In GsdMain
- In Init() function
- About to call the gsDesign constructor
- In gsDesign constructor
- Next line in code is call to ui->setupUi(this);...
- In DllMain
- This application has requested the Runtime to terminate it in an unusual way.
- Please contact the application's support team for more information.
- In DllMain
- Destructor called
- This application has requested the Runtime to terminate it in an unusual way.
- Please contact the application's support team for more information.
Here is the compilation and an example run. I decorated the code with some printf’s to show what is being called when. I do not understand the problem with QApplication as it was created many lines before the error shows up…
We are at a point, where only a small example (fully compilable, showing the problem) could help analyzing.
Gerolf:
I’m working on creating a small example that both looks like my project and replicates the problem.
In the meantime, it looks like the problem centers around the fact that the application resides in a global instance and QApplication is not set up when the thread is attached. What I mean is when you look at the output below, you can see that we enter process attach, start the initialization process, create a new QApplication and then when we try to instantiate a new instance of the main application class, we enter thread attach and the application then thinks that QApplication has not been instantiated and dies.
Not sure why this works on Linux and Mac, but not on Windows.
- > library(gsDesignExplorer)
- Loading required package: gsDesign
- Loading required package: ggplot2
- Loading required package: reshape
- Loading required package: plyr
- Attaching package: 'reshape'
- The following object(s) are masked from 'package:plyr':
- rename, round_any
- Loading required package: grid
- Loading required package: proto
- Loading required package: xtable
- GsdState constructor called!
- In DllMain, ul_reason_for_call = 1
- In DLL_PROCESS_ATTACH
- > gsDesignExplorer()
- In GsdStartup
- In GsdMain
- In Init() function
- About to call the gsDesign constructor
- In gsDesign constructor
- Next line in code is call to ui->setupUi(this);...
- In DllMain, ul_reason_for_call = 2
- In DLL_THREAD_ATTACH
- This application has requested the Runtime to terminate it in an unusual way.
- Please contact the application's support team for more information.
- In DllMain, ul_reason_for_call = 0
- In DLL_PROCESS_DETACH
- Destructor called
- This application has requested the Runtime to terminate it in an unusual way.
- Please contact the application's support team for more information.
Hi.
I’d like to up this post : doesn’t seem to have any solution here and, as it happens, i have the exact same problem : the setupUi method crashed without apparent reason.
And this only happen on Windows and on Release mode (the bug isn’t reproductible on Linux, or on Windows in debug mode).
I’m using Qt4.8.0, and I’m compiling with the MinGW provided with QtCreator.
Here is some code from the header :
- #ifndef LEVELEDITOR_H
- #define LEVELEDITOR_H
- #include <QWidget>
- #include "texturemanager.h"
- #include "objectmanager.h"
- namespace Ui {
- class LevelEditor;
- }
- {
- Q_OBJECT
- public:
- ~LevelEditor();
- public slots:
- private slots:
- void PickNewTexture(void);
- void TextureListIndexChanged(int);
- void TextureListUpdated(void);
- void CreateNewAnimation(void);
- void ObjectListIndexChanged(int);
- void CreateNewObject(void);
- void ObjectListUpdated(void);
- void UpdateLevelSize(void);
- void AddEntity(void);
- void DelEntity(void);
- private:
- Ui::LevelEditor *ui;
- TextureManager _textureManager;
- ObjectManager _objectManager;
- AnimationManager _animationManager;
- QString _currentLevel;
- };
- #endif // LEVELEDITOR_H
And here is the constructor :
- {
- qDebug() << "test1";
- ui->setupUi(this);
- qDebug() << "test2";
- }
And here goes the application output :
- test1
- The program has unexpectedly finished.
- C:\Users\Lovestospooge\Documents\Editor-build-desktop-Qt_4_8_0__4_8_0__Release\release\Editor.exe exited with code -1073741819
If, during the past half year, you found something that may cause this, I’d be glad to know.
If not, then you’re not the only one who met with this problem. And it may be interesting to get to the bottom of it :) !
You must log in to post a reply. Not a member yet? Register here!


