freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 6fb6a0b 3/7: [ftinspect] Remove file watching.


From: Werner LEMBERG
Subject: [freetype2-demos] master 6fb6a0b 3/7: [ftinspect] Remove file watching.
Date: Mon, 16 May 2016 05:56:44 +0000 (UTC)

branch: master
commit 6fb6a0bdba9e14d9bb70a3a77725914fac7ef58c
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [ftinspect] Remove file watching.
    
    This approach doesn't work well.  A new, improved implementation
    will follow.
    
    * src/ftinspect.h (Engine): Remove `currentFontFileInfo',
    `currentFontFileDate', `maxRetries', and `currentRetry'.
    Updated.
    (MainGUI): Remove `timer'.
    Updated.
    
    * src/ftinspect.cpp (Engine::watchCurrentFont): Removed.
    (Engine::loadFont, Engine::update): Updated.
    (MainGUI::MainGUI): Updated.
    (MainGUI::watchCurrentFont): Removed.
    (MainGUI::createConnections): Updated.
---
 ChangeLog         |   19 ++++++++++
 src/ftinspect.cpp |  104 -----------------------------------------------------
 src/ftinspect.h   |   12 -------
 3 files changed, 19 insertions(+), 116 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1641624..008b5e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2016-05-14  Werner Lemberg  <address@hidden>
 
+       [ftinspect] Remove file watching.
+
+       This approach doesn't work well.  A new, improved implementation
+       will follow.
+
+       * src/ftinspect.h (Engine): Remove `currentFontFileInfo',
+       `currentFontFileDate', `maxRetries', and `currentRetry'.
+       Updated.
+       (MainGUI): Remove `timer'.
+       Updated.
+
+       * src/ftinspect.cpp (Engine::watchCurrentFont): Removed.
+       (Engine::loadFont, Engine::update): Updated.
+       (MainGUI::MainGUI): Updated.
+       (MainGUI::watchCurrentFont): Removed.
+       (MainGUI::createConnections): Updated.
+
+2016-05-14  Werner Lemberg  <address@hidden>
+
        [ftinspect] Variable renaming.
 
        * src/ftinspect.cpp, src/ftinspect.h (FaceID):
diff --git a/src/ftinspect.cpp b/src/ftinspect.cpp
index 187f883..2a736dc 100644
--- a/src/ftinspect.cpp
+++ b/src/ftinspect.cpp
@@ -341,12 +341,6 @@ Engine::loadFont(int fontIndex,
     return -1;
   }
 
-  currentFontFileInfo.setFile(gui->fontList[fontIndex].filePathname);
-  currentFontFileInfo.setCaching(false);
-  currentFontDateTime = currentFontFileInfo.lastModified();
-  if (currentFontFileInfo.exists())
-    currentRetry = 0;
-
   curFamilyName = QString(ftSize->face->family_name);
   curStyleName = QString(ftSize->face->style_name);
 
@@ -362,83 +356,6 @@ Engine::loadFont(int fontIndex,
 }
 
 
-// this function must be followed by `showFont'
-// to reload the font if necessary
-
-bool
-Engine::watchCurrentFont()
-{
-  int index = gui->currentFontIndex;
-
-  if (index < 0)
-    return false;
-
-  Font& font = gui->fontList[index];
-
-  if (currentFontFileInfo.exists()
-      && currentFontFileInfo.isReadable())
-  {
-    QDateTime modified = currentFontFileInfo.lastModified();
-    if (modified > currentFontDateTime)
-    {
-      // the font has changed on disk; check whether we can load it,
-      // otherwise we increase our retry counter
-      FT_Face face;
-      if (FT_New_Face(library,
-                      qPrintable(font.filePathname),
-                      -1,
-                      &face))
-        goto Retry;
-
-      FT_Done_Face(face);
-
-      // remove all entries
-      for (int i = 0; i < font.numberOfNamedInstancesList.size(); i++)
-        for (int j = 0; j < font.numberOfNamedInstancesList[i]; j++)
-        {
-          removeFont(index, i, j);
-          gui->faceIDHash.remove(FaceID(index, i, j));
-        }
-      font.numberOfNamedInstancesList.clear();
-
-      currentRetry = 0;
-
-      // current face and instance indices should be preserved
-      return true;
-    }
-  }
-  else
-  {
-  Retry:
-    if (currentRetry < maxRetries)
-    {
-      currentRetry++;
-      return false;
-    }
-
-    // font is no longer available, thus replace all entries...
-    for (int i = 0; i < font.numberOfNamedInstancesList.size(); i++)
-      for (int j = 0; j < font.numberOfNamedInstancesList[i]; j++)
-      {
-        removeFont(index, i, j);
-        gui->faceIDHash.remove(FaceID(index, i, j));
-      }
-    font.numberOfNamedInstancesList.clear();
-
-    // ...with an invalid one
-    font.numberOfNamedInstancesList.append(0);
-
-    // XXX move this to MainGUI::watchCurrentFont
-    gui->currentFaceIndex = -1;
-    gui->currentNamedInstanceIndex = -1;
-
-    // XXX emit a warning message
-  }
-
-  return false;
-}
-
-
 void
 Engine::removeFont(int fontIndex,
                    int faceIndex,
@@ -642,9 +559,6 @@ Engine::update()
     scaler.x_res = dpi;
     scaler.y_res = dpi;
   }
-
-  // XXX make this configurable
-  maxRetries = 10;
 }
 
 
@@ -1198,11 +1112,6 @@ MainGUI::MainGUI()
 {
   engine = NULL;
 
-  // we are going to watch the current font file once in a second
-  timer = new QTimer();
-  timer->setInterval(1000);
-//  timer->start();
-
   setGraphicsDefaults();
   createLayout();
   createConnections();
@@ -1862,16 +1771,6 @@ MainGUI::zoom()
 
 
 void
-MainGUI::watchCurrentFont()
-{
-  if (engine->watchCurrentFont())
-    showFont(true);
-  else
-    showFont(false);
-}
-
-
-void
 MainGUI::setGraphicsDefaults()
 {
   // color tables (with suitable opacity values) for converting
@@ -2392,9 +2291,6 @@ MainGUI::createConnections()
   glyphNavigationMapper->setMapping(toP100Buttonx, 100);
   glyphNavigationMapper->setMapping(toP1000Buttonx, 1000);
   glyphNavigationMapper->setMapping(toEndButtonx, 0x10000);
-
-  connect(timer, SIGNAL(timeout()),
-          SLOT(watchCurrentFont()));
 }
 
 
diff --git a/src/ftinspect.h b/src/ftinspect.h
index a884fae..90902a6 100644
--- a/src/ftinspect.h
+++ b/src/ftinspect.h
@@ -53,7 +53,6 @@
 #include <QStandardItemModel>
 #include <QStatusBar>
 #include <QTabWidget>
-#include <QTimer>
 #include <QTransform>
 #include <QVariant>
 #include <QVector2D>
@@ -123,7 +122,6 @@ public:
   void setCFFHintingMode(int);
   void setTTInterpreterVersion(int);
   void update();
-  bool watchCurrentFont(); // returns `true' if we have to preserve indices
 
   friend class MainGUI;
 
@@ -138,13 +136,6 @@ public:
 private:
   MainGUI* gui;
 
-  QFileInfo currentFontFileInfo;
-  QDateTime currentFontDateTime;
-  int maxRetries; // how often we try to reload a font
-                  // if it suddenly disappears (because it is
-                  // in the process of being regenerated)
-  int currentRetry;
-
   QString curFamilyName;
   QString curStyleName;
 
@@ -353,7 +344,6 @@ private slots:
   void previousFace();
   void previousFont();
   void previousInstance();
-  void watchCurrentFont();
   void zoom();
 
 private:
@@ -483,8 +473,6 @@ private:
 
   QTabWidget *tabWidget;
 
-  QTimer *timer;
-
   QVBoxLayout *generalTabLayout;
   QVBoxLayout *leftLayout;
   QVBoxLayout *rightLayout;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]