From 9fa78476a44dcdfb0e219741289fb08509a380d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 9 Apr 2016 02:04:45 +0200 Subject: [PATCH] Version 15.190.2 --- swad_changelog.h | 3 ++- swad_image.c | 20 ++++++++++++++------ swad_image.h | 2 ++ swad_test.c | 20 ++++++++++++-------- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 77a27a804..3443e3401 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -133,13 +133,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.190.1 (2016-04-08)" +#define Log_PLATFORM_VERSION "SWAD 15.190.2 (2016-04-09)" #define CSS_FILE "swad15.190.1.css" #define JS_FILE "swad15.190.1.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.190.2: Apr 09, 2016 Fixed bug in test images. (199144 lines) Version 15.190.1: Apr 08, 2016 Removed unused JavaScript code. (199132 lines) Version 15.190: Apr 08, 2016 Get image attached to a social comment. (199142 lines) 2 changes necessary in database: diff --git a/swad_image.c b/swad_image.c index f4f635f94..30a7e4f7d 100644 --- a/swad_image.c +++ b/swad_image.c @@ -63,8 +63,6 @@ extern struct Globals Gbl; /***************************** Internal prototypes ***************************/ /*****************************************************************************/ -static void Img_FreeImageTitle (struct Image *Image); - static void Img_ProcessImage (const char *FileNameImgOriginal, const char *FileNameImgProcessed, unsigned Width,unsigned Height,unsigned Quality); @@ -72,20 +70,30 @@ static void Img_ProcessImage (const char *FileNameImgOriginal, /*****************************************************************************/ /*************************** Reset image fields ******************************/ /*****************************************************************************/ -// Every struct Image must be initialized to zero where it is declared -// Every call to Img_InitImage must have a call to Img_FreeImage +// Every struct Image must be initialized with this function Img_ImageConstructor after it is declared +// Every call to Img_ImageConstructor must have a call to Img_ImageDestructor void Img_ImageConstructor (struct Image *Image) + { + Img_ResetImageExceptTitle (Image); + Image->Title = NULL; + } + +/*****************************************************************************/ +/********************* Reset image fields except title ***********************/ +/*****************************************************************************/ + +void Img_ResetImageExceptTitle (struct Image *Image) { Image->Action = Img_ACTION_NO_IMAGE; Image->Status = Img_FILE_NONE; Image->Name[0] = '\0'; - Image->Title = NULL; } /*****************************************************************************/ /******************************** Free image *********************************/ /*****************************************************************************/ +// Every call to Img_ImageConstructor must have a call to Img_ImageDestructor void Img_ImageDestructor (struct Image *Image) { @@ -96,7 +104,7 @@ void Img_ImageDestructor (struct Image *Image) /*************************** Reset image title *******************************/ /*****************************************************************************/ -static void Img_FreeImageTitle (struct Image *Image) +void Img_FreeImageTitle (struct Image *Image) { // Image->Title must be initialized to NULL after declaration if (Image->Title) diff --git a/swad_image.h b/swad_image.h index 89a41c2c7..a09a3099b 100644 --- a/swad_image.h +++ b/swad_image.h @@ -96,7 +96,9 @@ struct Image /*****************************************************************************/ void Img_ImageConstructor (struct Image *Image); +void Img_ResetImageExceptTitle (struct Image *Image); void Img_ImageDestructor (struct Image *Image); +void Img_FreeImageTitle (struct Image *Image); void Img_GetImageNameAndTitleFromRow (const char *Name,const char *Title, struct Image *Image); diff --git a/swad_test.c b/swad_test.c index 85fba05f0..ddbef02ba 100644 --- a/swad_test.c +++ b/swad_test.c @@ -221,7 +221,7 @@ static void Tst_PutFormEditOneQst (char *Stem,char *Feedback); static void Tst_FreeTextChoiceAnswers (void); static void Tst_FreeTextChoiceAnswer (unsigned NumOpt); -// static void Tst_InitImagesOfQuestion (void); +static void Tst_InitImagesOfQuestion (void); static void Tst_FreeImagesOfQuestion (void); static void Tst_GetQstDataFromDB (char *Stem,char *Feedback); @@ -4866,21 +4866,25 @@ static void Tst_FreeTextChoiceAnswer (unsigned NumOpt) /*****************************************************************************/ /***************** Initialize images of a question to zero *******************/ /*****************************************************************************/ -/* + static void Tst_InitImagesOfQuestion (void) { unsigned NumOpt; - ***** Initialize image ***** - Img_ResetImage (&Gbl.Test.Image); + /***** Initialize image *****/ + Img_ResetImageExceptTitle (&Gbl.Test.Image); + Img_FreeImageTitle (&Gbl.Test.Image); for (NumOpt = 0; NumOpt < Tst_MAX_OPTIONS_PER_QUESTION; NumOpt++) - ***** Initialize image ***** - Img_ResetImage (&Gbl.Test.Answer.Options[NumOpt].Image); + { + /***** Initialize image *****/ + Img_ResetImageExceptTitle (&Gbl.Test.Answer.Options[NumOpt].Image); + Img_FreeImageTitle (&Gbl.Test.Image); + } } -*/ + /*****************************************************************************/ /*********************** Free images of a question ***************************/ /*****************************************************************************/ @@ -5129,7 +5133,7 @@ void Tst_ReceiveQst (void) else // Question is wrong { /***** Whether images has been received or not, reset images *****/ - // Tst_InitImagesOfQuestion (); + Tst_InitImagesOfQuestion (); /***** Put form to edit question again *****/ Tst_PutFormEditOneQst (Stem,Feedback);