Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Fixed UTF8 option was not effective by file reading and writing of a …
Browse files Browse the repository at this point in the history
…query.

Per report from Claudia. Thanks!
and Fixed crash at the time of file save. This was in some other reports.


git-svn-id: svn://svn.pgadmin.org/branches/REL-1_6_0_PATCHES@6413 a7884b65-44f6-0310-8a51-81a127f17b15
  • Loading branch information
Hiroshi Saito committed Jul 5, 2007
1 parent 94454a2 commit ef29fcf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Expand Up @@ -35,6 +35,9 @@ Changes

Date Dev Ver Change details
---------- --- ----- --------------
2007-07-05 HS 1.6.4 Fixed UTF8 option was not effective by file reading and
writing of a query. and fixed crash at the time of file
save. Per report from Claudia.
2007-03-30 DP 1.6.4 Avoid creating graphical explain nodes for triggers as
they aren't part of the plan and mess up the layout.
Per report from Jeremy Drake.
Expand Down
30 changes: 22 additions & 8 deletions src/frm/frmQuery.cpp
Expand Up @@ -32,6 +32,7 @@
#include "dlgAddFavourite.h"
#include "dlgManageFavourites.h"
#include "favourites.h"
#include "utffile.h"
#include "frmReport.h"

#include <wx/clipbrd.h>
Expand Down Expand Up @@ -1069,7 +1070,7 @@ void frmQuery::OnSelectFavourite(wxCommandEvent &event)
sqlQuery->AddText(fav->GetContents());
}


bool frmQuery::CheckChanged(bool canVeto)
{
if (changed && settings->GetAskSaveConfirmation())
Expand Down Expand Up @@ -1158,7 +1159,13 @@ void frmQuery::OnPositionStc(wxStyledTextEvent& event)

void frmQuery::OpenLastFile()
{
wxString str=FileRead(lastPath);
wxString str;
bool modeUnicode = settings->GetUnicodeFile();
wxUtfFile file(lastPath, wxFile::read, modeUnicode ? wxFONTENCODING_UTF8:wxFONTENCODING_DEFAULT);

if (file.IsOpened())
file.Read(str);

if (!str.IsEmpty())
{
sqlQuery->SetText(str);
Expand Down Expand Up @@ -1196,14 +1203,19 @@ void frmQuery::OnOpen(wxCommandEvent& event)

void frmQuery::OnSave(wxCommandEvent& event)
{
bool modeUnicode = settings->GetUnicodeFile();

if (lastPath.IsNull())
{
OnSaveAs(event);
return;
}

if (FileWrite(lastPath, sqlQuery->GetText(), -1))
{
wxUtfFile file(lastPath, wxFile::write, modeUnicode ? wxFONTENCODING_UTF8:wxFONTENCODING_DEFAULT);
if (file.IsOpened())
{
file.Write(sqlQuery->GetText());
file.Close();
changed=false;
setExtendedTitle();
UpdateRecentFiles();
Expand All @@ -1227,26 +1239,28 @@ void frmQuery::OnSaveAs(wxCommandEvent& event)
switch (dlg->GetFilterIndex())
{
case 0:
lastFileFormat = false;
#ifdef __WXMAC__
if (!lastPath.Contains(wxT(".")))
lastPath += wxT(".sql");
#endif
break;
case 1:
lastFileFormat = true;
#ifdef __WXMAC__
if (!lastPath.Contains(wxT(".")))
lastPath += wxT(".sql");
#endif
break;
default:
lastFileFormat = settings->GetUnicodeFile();
break;
}

if (FileWrite(lastPath, sqlQuery->GetText(), lastFileFormat ? 1 : 0))
lastFileFormat = settings->GetUnicodeFile();

wxUtfFile file(lastPath, wxFile::write, lastFileFormat ? wxFONTENCODING_UTF8:wxFONTENCODING_DEFAULT);
if (file.IsOpened())
{
file.Write(sqlQuery->GetText());
file.Close();
changed=false;
setExtendedTitle();
UpdateRecentFiles();
Expand Down

0 comments on commit ef29fcf

Please sign in to comment.