Browse Source

Ajout d'un lock sur la bdd.

Correction de la SIGSEV lors de la sortie du programme.
Ajout d'une exception (encore) sur parsefetch().
master
Maxime Wack 11 years ago
parent
commit
23fd3cc574
8 changed files with 58 additions and 44 deletions
  1. +9
    -1
      CosMoS/bdd.cpp
  2. +2
    -0
      CosMoS/bdd.h
  3. +12
    -1
      CosMoS/cosmos.cpp
  4. +1
    -0
      CosMoS/cosmos.h
  5. +3
    -0
      CosMoS/cosmosGUI.cpp
  6. +10
    -9
      CosMoS/recherche.cpp
  7. +2
    -2
      Sante_Pub.workspace
  8. +19
    -31
      Sante_Pub.workspace.session

+ 9
- 1
CosMoS/bdd.cpp View File

@@ -2,7 +2,12 @@

class_bdd::class_bdd(const wxString& path_in, wxGrid* grid)
{
//TODO: lock sur la bdd
this->path_in = path_in;
if (wxFileExists(path_in + slash + "db.lck"))
{
wxMessageBox(_T("La base est actuellement en cours d'utilisation\nSi vous êtes certains que ce n'est pas le cas,\nsupprimez le fichier db.lck situé dans le même répertoire"));
exit(0);
}
this->grid = grid;
wxString path = path_in + slash + "cosmos.db";
if (!wxFileExists(path))
@@ -12,11 +17,14 @@ class_bdd::class_bdd(const wxString& path_in, wxGrid* grid)
wxMessageBox(_T("Erreur lors de l'ouverture de la base de données"), "Erreur", wxICON_ERROR | wxOK);
exit(0);
}
wxFile* lock = new wxFile(path_in + slash + "db.lck", wxFile::write);
lock->Close();
}

class_bdd::~class_bdd()
{
rc = sqlite3_close(db); //check RC (busy ?)
wxRemoveFile(path_in + slash + "db.lck");
if (rc == SQLITE_BUSY)
wxMessageBox("Busy");
}


+ 2
- 0
CosMoS/bdd.h View File

@@ -2,6 +2,7 @@
#define __bdd__

#include <wx/filefn.h>
#include <wx/file.h>
#include <wx/ffile.h>
#include <wx/msgdlg.h>
#include <wx/progdlg.h>
@@ -17,6 +18,7 @@ class class_bdd
sqlite3_stmt* stmt, *stmt_correc;
int rc;
wxGrid* grid;
wxString path_in;
void createEmpty(const wxString& path);
public:


+ 12
- 1
CosMoS/cosmos.cpp View File

@@ -48,7 +48,18 @@ void cosmos::OnQuit( wxCommandEvent& event )
delete bdd;
delete fenetre_options;
delete configuration;
this->Close();
exit(0);
}

void cosmos::OnQuit( wxCloseEvent& event )
{
delete fenetre_resultats;
delete recherche;
delete fenetre_corrections;
delete bdd;
delete fenetre_options;
delete configuration;
exit(0);
}

void cosmos::OnStart( wxCommandEvent& event )


+ 1
- 0
CosMoS/cosmos.h View File

@@ -30,6 +30,7 @@ protected:
void OnImport( wxCommandEvent& event );
void OnExport( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event );
void OnQuit( wxCloseEvent& event );
void OnStart( wxCommandEvent& event );
void OnOptionsRche( wxCommandEvent& event );
void OnOptionsProg( wxCommandEvent& event );


+ 3
- 0
CosMoS/cosmosGUI.cpp View File

@@ -188,6 +188,9 @@ cosmosGUI::cosmosGUI( wxWindow* parent, wxWindowID id, const wxString& title, co

cosmosGUI::~cosmosGUI()
{
delete grid_Consults;
delete bool_editor;
delete bool_renderer;
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( cosmosGUI::OnQuit ) );
this->Disconnect( wxID_OPEN, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( cosmosGUI::OnImport ) );


+ 10
- 9
CosMoS/recherche.cpp View File

@@ -14,8 +14,6 @@ class_recherche::class_recherche(config* configuration, class_bdd* bdd, wxGrid*

class_recherche::~class_recherche()
{
if (curldata.content)
free (curldata.content);
curl_easy_cleanup (curlhandle);
curl_global_cleanup ();
}
@@ -112,7 +110,10 @@ void class_recherche::parsefetch()
if (parcours->FirstChildElement("Year"))
date << parcours->FirstChildElement("Year")->GetText(); // *Year
parcours = parcours->Parent()->ToElement(); // JournalIssue
revue << parcours->NextSiblingElement("ISOAbbreviation")->GetText(); // *ISOAbbreviation
if (parcours->NextSiblingElement("ISOAbbreviation"))
revue << parcours->NextSiblingElement("ISOAbbreviation")->GetText(); // *ISOAbbreviation
else if (parcours->NextSiblingElement("Title"))
revue << parcours->NextSiblingElement("Title")->GetText();
parcours = parcours->Parent()->ToElement(); // Journal
titre << parcours->NextSiblingElement("ArticleTitle")->GetText(); // *ArticleTitle
if (parcours->NextSiblingElement("Abstract"))
@@ -185,10 +186,10 @@ void class_recherche::efetch()
{
accessdenied = true;
time_t timer = time(NULL);
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 120, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 120))
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 200))
progress_dialog.Update(time(NULL) - timer);
progress_dialog.Update(120);
progress_dialog.Update(200);
if (curldata.content)
free (curldata.content);
}
@@ -258,10 +259,10 @@ void class_recherche::esearch(wxString requete)
{
accessdenied = true;
time_t timer = time(NULL);
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 120, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 120))
wxProgressDialog progress_dialog("Erreur proxy", _T("En attente du proxy"), 200, NULL, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
while (time(NULL) < (timer + 200))
progress_dialog.Update(time(NULL) - timer);
progress_dialog.Update(120);
progress_dialog.Update(200);
if (curldata.content)
free (curldata.content);
}


+ 2
- 2
Sante_Pub.workspace View File

@@ -17,7 +17,7 @@
]]>
</Environment>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<WorkspaceConfiguration Name="Debug" Selected="no">
<Project Name="COSMOS" ConfigName="Debug"/>
<Project Name="CosMoS" ConfigName="Debug"/>
<Project Name="grid" ConfigName="Debug"/>
@@ -31,7 +31,7 @@
<Project Name="testcurl" ConfigName="Release"/>
<Project Name="testsqlite" ConfigName="Release"/>
</WorkspaceConfiguration>
<WorkspaceConfiguration Name="Debug_WIN" Selected="no">
<WorkspaceConfiguration Name="Debug_WIN" Selected="yes">
<Project Name="CosMoS" ConfigName="Debug_WIN"/>
<Project Name="grid" ConfigName="Debug_WIN"/>
<Project Name="testcurl" ConfigName="Debug_WIN"/>


+ 19
- 31
Sante_Pub.workspace.session View File

@@ -1,54 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Session Name="/home/satamaxx/Programmes/Sante_Pub/Sante_Pub.workspace">
<int Value="4" Name="m_selectedTab"/>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/Sante_Pub.workspace" Name="m_workspaceName"/>
<?xml version="1.0" encoding="UTF-8"?>
<Session Name="C:\Projets\Sante_Pub.workspace">
<int Value="5" Name="m_selectedTab"/>
<wxString Value="C:\Projets\Sante_Pub.workspace" Name="m_workspaceName"/>
<TabInfoArray Name="TabInfoArray">
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/cosmos.cpp" Name="FileName"/>
<wxString Value="C:\Projets\CosMoS\misc.h" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="0" Name="CurrentLine"/>
<int Value="12" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultatsGUI.h" Name="FileName"/>
<int Value="7" Name="FirstVisibleLine"/>
<int Value="7" Name="CurrentLine"/>
<wxString Value="C:\Projets\CosMoS\cosmos.h" Name="FileName"/>
<int Value="3" Name="FirstVisibleLine"/>
<int Value="32" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultatsGUI.cpp" Name="FileName"/>
<int Value="7" Name="FirstVisibleLine"/>
<int Value="7" Name="CurrentLine"/>
<wxString Value="C:\Projets\CosMoS\cosmos.cpp" Name="FileName"/>
<int Value="41" Name="FirstVisibleLine"/>
<int Value="61" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultats.h" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="22" Name="CurrentLine"/>
<wxString Value="C:\Projets\CosMoS\bdd.h" Name="FileName"/>
<int Value="2" Name="FirstVisibleLine"/>
<int Value="4" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/resultats.cpp" Name="FileName"/>
<wxString Value="C:\Projets\CosMoS\bdd.cpp" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="20" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/recherche.cpp" Name="FileName"/>
<int Value="1" Name="FirstVisibleLine"/>
<int Value="2" Name="CurrentLine"/>
<int Value="25" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/bdd.h" Name="FileName"/>
<wxString Value="C:\Projets\CosMoS\resultats.cpp" Name="FileName"/>
<int Value="0" Name="FirstVisibleLine"/>
<int Value="40" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
<TabInfo>
<wxString Value="/home/satamaxx/Programmes/Sante_Pub/CosMoS/bdd.cpp" Name="FileName"/>
<int Value="336" Name="FirstVisibleLine"/>
<int Value="353" Name="CurrentLine"/>
<int Value="14" Name="CurrentLine"/>
<wxArrayString Name="Bookmarks"/>
</TabInfo>
</TabInfoArray>


Loading…
Cancel
Save