On Thu, Apr 18, 2019 at 6:22 PM Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> wrote: > > By default the "Last session" configuration file will be saved in > ${HOME}/.cache/kernelshark. If ${HOME}/.cache/kernelshark doesn't exist, > it will be created automatically. The user can select another directory > to be used to store the cached data. This can be done by setting the > environment variable KS_USER_CACHE_DIR. In this case if the path (the > value of KS_USER_CACHE_DIR) doesn't exist the user will be asked before > create it. > > Suggested-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> > Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> > > Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> Nit: two identical Signed-off-by tags > --- > kernel-shark/src/KsMainWindow.cpp | 68 +++++++++++++++++++++++++++---- > kernel-shark/src/KsMainWindow.hpp | 4 ++ > 2 files changed, 63 insertions(+), 9 deletions(-) > > diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp > index 7afb721..cf2db74 100644 > --- a/kernel-shark/src/KsMainWindow.cpp > +++ b/kernel-shark/src/KsMainWindow.cpp [...] > -void KsMainWindow::_restoreSession() > +QString KsMainWindow::_getCacheDir() > +{ > + QString dir; > + > + auto lamMakePath = [&] (bool ask) { > + if (ask) { > + QMessageBox::StandardButton reply; > + QString err("KernelShark cache directory not found!\n"); > + QString question = > + QString("Do you want to create %1").arg(dir); > + > + reply = QMessageBox::question(this, "KernelShark", > + err + question, > + QMessageBox::Yes | > + QMessageBox::No); > + > + if (reply == QMessageBox::No) { > + dir.clear(); > + return; > + } > + } > + > + QDir().mkpath(dir); > + }; > + > + dir = getenv("KS_USER_CACHE_DIR"); > + if (!dir.isEmpty()) { > + if (!QDir(dir).exists()) > + lamMakePath(true); > + } else { > + dir = QString(getpwuid(getuid())->pw_dir) + > + "/.cache/kernelshark"; Nit: s/QString(getpwuid(getuid())->pw_dir)/QDir::homePath()/ Everything else looks great with the patch Reviewed-by: Slavomir Kaslev <kaslevs@xxxxxxxxxx> Cheers, --Slavi