Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Small Bug in Scripted wizard?
(1/1)
danselmi:
I think I found a bug in the scripted wizard plugin. But I am quite new to this part of C::B. So here is what I found:
Before a file gets generated within GenerateFile(), the check if the file does exist is done in the directory of the project which was active when the wizard was started. So it complains that a file already exists but is is in a different project. (It even askes if it can overwrite the file.)
Is there a reason to not move the check to the point where the full path is constructed?
--- Code: ---Index: wiz.cpp
===================================================================
--- wiz.cpp (revision 7713)
+++ wiz.cpp (working copy)
@@ -667,22 +667,6 @@
{
wxFileName fname(filename);
- if ( fname.FileExists() )
- {
- wxString query_overwrite;
- query_overwrite.Printf(
- _T("Warning:\n")
- _T("The wizard is about OVERWRITE the following existing file:\n")+
- fname.GetFullPath()+_T("\n\n")+
- _T("Are you sure that you want to OVERWRITE the file?\n\n")+
- _T("(If you answer 'No' the existing file will be kept.)"));
- if (cbMessageBox(query_overwrite, _T("Confirmation"),
- wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT) == wxID_NO)
- {
- return fname.GetFullPath();
- }
- }
-
// extension sanity check
FileType ft = FileTypeOf(fname.GetFullPath());
switch (ft)
@@ -731,6 +715,21 @@
}
fname = basePath + wxFILE_SEP_PATH + fname.GetFullPath();
+ if ( fname.FileExists() )
+ {
+ wxString query_overwrite;
+ query_overwrite.Printf(
+ _T("Warning:\n")
+ _T("The wizard is about OVERWRITE the following existing file:\n")+
+ fname.GetFullPath()+_T("\n\n") +
+ _T("Are you sure that you want to OVERWRITE the file?\n\n")+
+ _T("(If you answer 'No' the existing file will be kept.)"));
+ if (cbMessageBox(query_overwrite, _T("Confirmation"),
+ wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT) == wxID_NO)
+ {
+ return fname.GetFullPath();
+ }
+ }
// create the file with the passed contents
wxFileName::Mkdir(fname.GetPath(),0777,wxPATH_MKDIR_FULL);
--- End code ---
MortenMacFly:
--- Quote from: danselmi on January 24, 2012, 07:32:29 pm ---Is there a reason to not move the check to the point where the full path is constructed?
--- End quote ---
No, this might be a bug introduced with changes done in the project management... some time ago already. ::)
Jenna:
--- Quote from: danselmi on January 24, 2012, 07:32:29 pm ---Is there a reason to not move the check to the point where the full path is constructed?
--- End quote ---
I don't see any reasons, not to move, but one reason to move it, because it overwrites files without asking, and that should of course not happen.
So my opinion:
it should definitely be committed, because it really is a (serious) bug and acts contrary to what it is meant to do.
Navigation
[0] Message Index
Go to full version