PDA

View Full Version : Bug in the .ui file



Momergil
25th January 2013, 03:04
Hello!

I think I found a big problem :P

I had some QCheckBox declared in my mainwindow.ui file and some toggled(bool) functions related to them in my mainwindow.cpp/h and I decided to change theyr names. Instead though of going to the Design interface in QtCreator and change theyr names in the specific place and than go to the .cpp and change the names of the functions, I decided to do a "replace all" in QtCreator thinking that this would be the quickest way.

After changing some code on which seems to be the ui source code, I went back to the Designer interface in the .ui and found out that the QCheckBoxes's names weren't changed there. So I edited them mannually. Than I run the app and I found out that the toogled(bool) functions also hadn't theyr names changed, so I went to the .cpp and changed them too (in other words, my trying to be smart by using replace all went for nothing).

But after this, I tried to enter again in the mainwindow.ui file in the Designer interface and QtCreator didn't allowed me, saying "An enconding error was encountered" in a pop up. After several times trying, I decided to do the procces Clean All - Run Qmake - Rebuild All, and than a new error appeared:



00:57:15: Running build steps for project mShare...
00:57:15: Configuration unchanged, skipping qmake step.
00:57:15: Starting: "C:\QtSDK\mingw\bin\mingw32-make.exe"
C:/QtSDK/mingw/bin/mingw32-make.exe -f Makefile.Release
mingw32-make.exe[1]: Entering directory `D:/Minhas obras/Softwares/mShare/mShare 0.0.7'
c:\QtSDK\Desktop\Qt\4.8.1\mingw\bin\uic.exe mainwindow.ui -o ui_mainwindow.h
mingw32-make.exe[1]: Leaving directory `D:/Minhas obras/Softwares/mShare/mShare 0.0.7'
uic: Error in line 1751, column 16 : Encountered incorrectly encoded content.
File 'mainwindow.ui' is not valid
mingw32-make.exe[1]: *** [ui_mainwindow.h] Error 1
mingw32-make.exe: *** [release] Error 2
00:57:15: The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
Error while building project mShare (target: Desktop)
When executing build step 'Make'


So now I can't compile my software as well as I can't have acces to the .ui file. :(

How can I fix this problem? I would attach the .ui file here but the forum's limits didn't allowed me because of size limitations. I also went to this 1751 line and found nothing - I guess is because I'm looking at the mainwindow.ui file, not ui_mainwindonw.h which by the way is missing.


Urgent help please :)


Thanks in advance,

Momergil

Santosh Reddy
25th January 2013, 04:15
The way I see out is to either
1. Revert back to some wokring code (all .cpp/.h/.ui)
or
2. Try to manually recover the ui file.

I can help you out in recovering the file, if you wish to. (also mention the Qt version you are using)

Momergil
25th January 2013, 12:00
The way I see out is to either
1. Revert back to some wokring code (all .cpp/.h/.ui)
or
2. Try to manually recover the ui file.

I can help you out in recovering the file, if you wish to. (also mention the Qt version you are using)


Well technically I may use both of the options. I mean, I have a backup .ui file but I'm quite unsure about to use it because I'm not sure I'll remember all the changes - and they were quite a few. And also that may take quite a considerable time.

About the second option, I'm glad it can be solved so, but in that case what should I do? attach the .ui doesn't sees to be possible here in the forum. Besides, could it be too much difficult to find the error or this can be done quickly? Because I don't want to waste your time :T

Using Qt 4.8.1.

Santosh Reddy
25th January 2013, 12:17
It should be fairly possible to fix the ui file (assuming basics of xml, and Qt Designer Properties)

Try comparing the old and new ui files using a text compare tool.

As I don't know to what extent your ui file is corrupted, it is difficult to say extent of recovery that can be done.

It shoud be possible to zip the ui file the attach in the post, unless you don't want to put the ui file in public.

Momergil
25th January 2013, 18:44
It should be fairly possible to fix the ui file (assuming basics of xml, and Qt Designer Properties)

Try comparing the old and new ui files using a text compare tool.

As I don't know to what extent your ui file is corrupted, it is difficult to say extent of recovery that can be done.

It shoud be possible to zip the ui file the attach in the post, unless you don't want to put the ui file in public.

Well, it would be fairly possible if any mistake could be seen :X I tried comparying the oldest backup version with the current bugged .ui and had little success identifying differences: the greatest of them were in natural difference that came with the development, and the unique strange difference was in the encoding of special characteres (~, ç, etc..) which were some times different from one file to the other. But after changing the new .ui file to the older's way of writing theese special characters, nothing changed. In fact Qt Creator pointed out a specific line and column were the mistake is supposed to be, and I found nothing at all there:



<property name="prefix">


(Column 16 would be the first "r" of "property")

Edit: I tried to attach a .rar file of mainwindow.ui, but once again the forum didn't allow me affirming that it was a "invalid file".

Momergil
26th January 2013, 00:47
Very interestingly, I managed to correct the problem.

What I did was, instead of sumply looking at the .ui file in a text editor and trying to find the problem or else simply comparing the last backup version of mainwindow.ui and the bugged, newest version, I renamed the bugged one to a invalid name and copied the backup file to the project's file system and than began to ctrl+c + ctrl+v the parts from the bugged version to the backup/new one part by part, going back to QtCreator to see if a problem appeared. The unique time that this happens was, it seems, due to the question posted below, but with that exception, a simple copy-and-paste solved the problem. In other words, now I have a new mainwinwindow.ui that is essentially the same as the bugged version but that runs everything fine o.O

So I guess that is some kind of bug in QtCreator... no reason, in terms of code, for this to happen.

Well, last question: is there a difference between

<widget class="QComboBox" name="GraphToolbarCharttype"/>

and

<widget class="QComboBox" name="GraphToolbarCharttype">

(i.e. without / at the end)? Because it seems that the only once that the problem appeared again was because of the presence of this / at the end of a similar code. Nevertheless, the current mainwindow.ui, that runs fine, is using the first and not the second case.


Thanks,

Momergil

Santosh Reddy
26th January 2013, 12:06
That makes sense.

The second xml node is not closed/terminated or it would throw error in ui file parsing.. :)

wysota
26th January 2013, 19:26
So I guess that is some kind of bug in QtCreator... no reason, in terms of code, for this to happen.
It's not a bug in Qt Creator. Somewhere in your file you used a character that is invalid in context of XML. While copy&pasting, your system somehow corrected it to the proper character or discarded the (possibly not-printable) character.


Well, last question: is there a difference between

<widget class="QComboBox" name="GraphToolbarCharttype"/>

and

<widget class="QComboBox" name="GraphToolbarCharttype">
Yes. The second one opens a tag called widget while the first one both opens and closes a tag called widget.