Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, January 2008
Odd QFileDialog behavior


Message 1 in thread

I've discovered something that I think is a little odd about QFileDialog
today but maybe I'm just simply doing something wrong.

My code looks like this:

void MainWindow::createNewProject()
{	
	QString file = QFileDialog::getSaveFileName(this, "New Project",
QString(), "iEDA Project (*.iedaproject)", 0);
	
	if(file.size() > 0)
	{
		QFileInfo info(file);
		Project* project = Project::createNew(info.baseName(),
info.filePath());
		project->save();
	}
}

Now, if I double click on an existing file in the Dialog and choose "No"
to the overwrite prompt, the dialog closes and returns the file name of
the file I did not want to overwrite.

I also tested this with the exec() as well and the same behavior. exec()
returns Dialog::Accepted when choosing "No" to an overwrite prompt.

Am I doing something wrong or is this a possible bug?

Stephan


--
 [ signature omitted ] 

Message 2 in thread

Stephan Rose wrote:
>Am I doing something wrong or is this a possible bug?

I remember this bug. I think it was introduced while fixing a much more 
severe bug in 4.3.3 (namely, it would delete the file you have before you 
had the chance to reply Yes or No).

It will be fixed in 4.3.4. Can you test the snapshots to see if this bug 
was fixed?

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread

On Tue, 2008-01-01 at 17:59 -0200, Thiago Macieira wrote:
> Stephan Rose wrote:
> >Am I doing something wrong or is this a possible bug?
> 
> I remember this bug. I think it was introduced while fixing a much more 
> severe bug in 4.3.3 (namely, it would delete the file you have before you 
> had the chance to reply Yes or No).
> 
> It will be fixed in 4.3.4. Can you test the snapshots to see if this bug 
> was fixed?
> 

I couldn't find a 4.3.4 snapshot (or anything about 4.3.4 for that
matter) so I tested it with the 4.4.0 snapshot.

It looks like it is fixed in 4.4.0! 

Stephan


--
 [ signature omitted ] 

Message 4 in thread

Please tell me this will be fixed soon in 4.3.4. We are freezing code and
will NOT move to 4.4.x (too many changes). This is a serious bug as it has
the potential to destroy data.

Keith
**Please do not reply to me, reply to the list.**

On 01-01-2008 5:17 PM, "Stephan Rose" wrote:

> 
> On Tue, 2008-01-01 at 17:59 -0200, Thiago Macieira wrote:
>> Stephan Rose wrote:
>>> Am I doing something wrong or is this a possible bug?
>> 
>> I remember this bug. I think it was introduced while fixing a much more
>> severe bug in 4.3.3 (namely, it would delete the file you have before you
>> had the chance to reply Yes or No).
>> 
>> It will be fixed in 4.3.4. Can you test the snapshots to see if this bug
>> was fixed?
>> 
> 
> I couldn't find a 4.3.4 snapshot (or anything about 4.3.4 for that
> matter) so I tested it with the 4.4.0 snapshot.
> 
> It looks like it is fixed in 4.4.0!
> 
> Stephan
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 


--
 [ signature omitted ] 

Message 5 in thread

On Wed, 2008-01-02 at 11:13 -0600, Keith Esau wrote: 
> Please tell me this will be fixed soon in 4.3.4. We are freezing code and
> will NOT move to 4.4.x (too many changes). This is a serious bug as it has
> the potential to destroy data.

If someone can direct me to a link where I can get the 4.3.4 snapshot
I'll be glad to test it. If I go into my ftp download directories, I
can't find any mention of 4.3.4 anywhere...

Stephan


--
 [ signature omitted ] 

Message 6 in thread

I just checked, and the last 4.3.x snapshot was made Dec. 7. It does not
appear that a 4.3.4 is in the works!

Keith
**Please do not reply to me, reply to the list.**


On 01-02-2008 11:21 AM, "Stephan Rose" wrote:

> 
> On Wed, 2008-01-02 at 11:13 -0600, Keith Esau wrote:
>> Please tell me this will be fixed soon in 4.3.4. We are freezing code and
>> will NOT move to 4.4.x (too many changes). This is a serious bug as it has
>> the potential to destroy data.
> 
> If someone can direct me to a link where I can get the 4.3.4 snapshot
> I'll be glad to test it. If I go into my ftp download directories, I
> can't find any mention of 4.3.4 anywhere...
> 
> Stephan


--
 [ signature omitted ] 

Message 7 in thread

Please have a look at
   ftp://ftp.trolltech.com/qt/snapshots

4.3.4 snapshots are now available.

Alessandro

Stephan Rose wrote:
> If someone can direct me to a link where I can get the 4.3.4 snapshot
> I'll be glad to test it. If I go into my ftp download directories, I
> can't find any mention of 4.3.4 anywhere...
> 
> Stephan

--
 [ signature omitted ] 

Message 8 in thread

I only use the commercial version...

Keith
**Please do not reply to me, reply to the list.**

On 01-02-2008 12:41 PM, "Alessandro Portale" wrote:

> Please have a look at
>    ftp://ftp.trolltech.com/qt/snapshots
> 
> 4.3.4 snapshots are now available.
> 
> Alessandro
> 
> Stephan Rose wrote:
>> If someone can direct me to a link where I can get the 4.3.4 snapshot
>> I'll be glad to test it. If I go into my ftp download directories, I
>> can't find any mention of 4.3.4 anywhere...
>> 
>> Stephan
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 


--
 [ signature omitted ] 

Message 9 in thread

Well I have a fix for it, it was really simple to find actually.

Just a case of missing curly braces for an if statement.

The file is:

src/gui/dialogs/qfiledialog.cpp

Line 1598 has this if statement:

if (QMessageBox::warning(this, windowTitle(), tr("%1 already exists.\nDo
you want to replace it?").arg(info.fileName()), QMessageBox::Yes |
QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
emit filesSelected(QStringList(fn));
QDialog::accept();

So the emit only gets executed if the user answers "Yes" but accept is
executed regardless of user choice.

So the Fix:

if (QMessageBox::warning(this, windowTitle(), tr("%1 already exists.\nDo
you want to replace it?").arg(info.fileName()), QMessageBox::Yes |
QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
{ 
	emit filesSelected(QStringList(fn));
	QDialog::accept(); 
}

Problem solved. I tested it, works as expected on my end under
X11/Linux. You'll have to implement the fix yourself though as I use the
commercial version and therefore won't make the changed file available
without explicit permission from Trolltech. That's their call.

Stephan


On Wed, 2008-01-02 at 13:01 -0600, Keith Esau wrote:
> I only use the commercial version...
> 
> Keith
> **Please do not reply to me, reply to the list.**
> 
> On 01-02-2008 12:41 PM, "Alessandro Portale" wrote:
> 
> > Please have a look at
> >    ftp://ftp.trolltech.com/qt/snapshots
> > 
> > 4.3.4 snapshots are now available.
> > 
> > Alessandro
> > 
> > Stephan Rose wrote:
> >> If someone can direct me to a link where I can get the 4.3.4 snapshot
> >> I'll be glad to test it. If I go into my ftp download directories, I
> >> can't find any mention of 4.3.4 anywhere...
> >> 
> >> Stephan
> > 
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> > "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
> > 
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 
> 

--
 [ signature omitted ] 

Message 10 in thread

Keith Esau wrote:
> Please tell me this will be fixed soon in 4.3.4. We are freezing code and
> will NOT move to 4.4.x (too many changes). This is a serious bug as it has
> the potential to destroy data.

You can easily work around this by turning off the CheckOverwrite flag 
in the file dialog and doing your own code to check if the file exists 
and ask for overwrite. Would add about 3 lines of code to each place 
where you use a Save dialog.

> 
> Keith
> **Please do not reply to me, reply to the list.**
> 
> On 01-01-2008 5:17 PM, "Stephan Rose" wrote:
> 
>> On Tue, 2008-01-01 at 17:59 -0200, Thiago Macieira wrote:
>>> Stephan Rose wrote:
>>>> Am I doing something wrong or is this a possible bug?
>>> I remember this bug. I think it was introduced while fixing a much more
>>> severe bug in 4.3.3 (namely, it would delete the file you have before you
>>> had the chance to reply Yes or No).
>>>
>>> It will be fixed in 4.3.4. Can you test the snapshots to see if this bug
>>> was fixed?
>>>
>> I couldn't find a 4.3.4 snapshot (or anything about 4.3.4 for that
>> matter) so I tested it with the 4.4.0 snapshot.
>>
>> It looks like it is fixed in 4.4.0!
>>
>> Stephan
>>
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
> 
> 


-- 
 [ signature omitted ] 

Message 11 in thread

On Wed, 2008-01-02 at 12:13 -0600, Paul Miller wrote:
> Keith Esau wrote:
> > Please tell me this will be fixed soon in 4.3.4. We are freezing code and
> > will NOT move to 4.4.x (too many changes). This is a serious bug as it has
> > the potential to destroy data.
> 
> You can easily work around this by turning off the CheckOverwrite flag 
> in the file dialog and doing your own code to check if the file exists 
> and ask for overwrite. Would add about 3 lines of code to each place 
> where you use a Save dialog.

True, that'll get the job done and probably is a decent workaround for
the time being but not really in the nicest of ways since the check
occurs after the user has selected the file accepted it in the dialog.
So then if the user chooses "no", the file dialog has to be reopened
again which would be unusual behavior.

I might actually go look into the QT source code and see if there isn't
a quick and easy fix with a recompile that could solve this until an
official fix is released...if I find something I'll post it to the list.

Stephan


--
 [ signature omitted ]