ksharindam / gospel-pdf-viewer

Poppler based fast pdf viewer written in PyQt5
GNU General Public License v3.0
10 stars 4 forks source link

Error while Running the code after cleaning recent file history #4

Closed sharoseali closed 8 months ago

sharoseali commented 8 months ago

Hi, first, thanks for your great work. I have installed the tool, and it is working fine on my Ubuntu 20.04. I import this tool into my main GUI to view PDFs; however, when I transfer the code to my new system (the same OS, Ubuntu 20.04), the code displays the content list but does not display the pdf. On cmd, I am getting the following message:

Traceback (most recent call last): File "/home/sharoze/WORK/pdfToImage/GUI_Work/newGUI/gospel-pdf-viewer/gospel_pdf/cost_Estimate_Main.py", line 491, in openFile self.loadPDFfile(filename) File "/home/sharoze/WORK/pdfToImage/GUI_Work/newGUI/gospel-pdf-viewer/gospel_pdf/cost_Estimate_Main.py", line 414, in loadPDFfile if collapseUser(self.filename) in self.history_filenames: TypeError: argument of type 'NoneType' is not iterable

Also, one thing more: even though I have selected multiple pdf files, recent history is not showing on my new system. Previous systems show history as well. Any suggestions here?

One more test On my previous system, the tool was working fine after clearing the recent history by pressing the button. I am getting this error.

sudo gospel-pdf 
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Traceback (most recent call last):
  File "/usr/local/bin/gospel-pdf", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/gospel_pdf/main.py", line 926, in main
    win = Window()
  File "/usr/local/lib/python3.8/dist-packages/gospel_pdf/main.py", line 221, in __init__
    self.addRecentFiles()
  File "/usr/local/lib/python3.8/dist-packages/gospel_pdf/main.py", line 231, in addRecentFiles
    for each in self.recent_files:
TypeError: 'NoneType' object is not iterable
QThread: Destroyed while thread is still running
Aborted

Now in both systems, its not working.

@ksharindam @dammhannes

ksharindam commented 8 months ago

Traceback (most recent call last): File "/home/sharoze/WORK/pdfToImage/GUI_Work/newGUI/gospel-pdf-viewer/gospel_pdf/cost_Estimate_Main.py", line 491, in openFile self.loadPDFfile(filename) File "/home/sharoze/WORK/pdfToImage/GUI_Work/newGUI/gospel-pdf-viewer/gospel_pdf/cost_Estimate_Main.py", line 414, in loadPDFfile if collapseUser(self.filename) in self.history_filenames: TypeError: argument of type 'NoneType' is not iterable

Why the filename is cost_Estimate_Main.py instead of main.py? Did you modify anything?

sharoseali commented 8 months ago

@ksharindam . This is just another name of gospel_pdf/main.py. I have also tried to run with ./run.sh and other commands provided in README but same problem coming.

After diving a bit more. I found that self.recent_files values gets None after clicking clean recent files button. At this moment this error is coming bcz as in code the cases is only handled if self.recent_files== "" but in actual after clearing history the value gets None .

I temporarily handled by just re assigning empty string as self.recent_files= "". It opes PDF without error but this time t even though its working, history is not being maintained. No files are appearing in Open Recent file

ksharindam commented 8 months ago

self.recent_files should be a list, instead of string. if it is empty, then it should be empty list [].

I dont understand why it is None. put a print(self.recent_files) after line no. 181, i.e after self.recent_files = self.settings.value("RecentFiles", [])

and show me the output

ksharindam commented 8 months ago

Finally found the problem. when the settings is saved with value empty list, is saves as @Invalid() when it is loaded by QSettings, returns None.

ksharindam commented 8 months ago

@sharoseali Thanks for pointing out the bug. It is now solved.

sharoseali commented 8 months ago

Thanks @ksharindam A quick question, can I use this tool on Windows also ? If so, then are dependencies wil be same ?

If you want i can open a new discussion.🙂

ksharindam commented 8 months ago

@sharoseali I hope it will work on Windows without any modification. And yes dependencies will be same. I am thinking of releasing exe package for windows and AppImage for linux.

sharoseali commented 8 months ago

@sharoseali I hope it will work on Windows without any modification. And yes dependencies will be same. I am thinking of releasing exe package for windows and AppImage for linux.

Great to hear about this. I need to run it own windows but python3-poppler-qt5 is really creating distrubance, if you have successfully installed this dependency then I'll be so great ful, if you can share the installation steps.

If you are ok, I can open a new issue for Windows OS.

ksharindam commented 8 months ago

How did you install poppler-qt5 ? I shall try to install it using pip. You can open as issue.

sharoseali commented 8 months ago

Thanks I have opened a new topic #5